summaryrefslogtreecommitdiffstats
path: root/net/url_request
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-10 18:03:39 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-10 18:03:39 +0000
commit8416157dd9a3e5bd61f605e1d420d8cf6a4ef9ca (patch)
tree90326da8fe65d9576a2e32cc39a8b224f313c2d4 /net/url_request
parent7f113f39afed41b39d5c937039879c5d822c6b5e (diff)
downloadchromium_src-8416157dd9a3e5bd61f605e1d420d8cf6a4ef9ca.zip
chromium_src-8416157dd9a3e5bd61f605e1d420d8cf6a4ef9ca.tar.gz
chromium_src-8416157dd9a3e5bd61f605e1d420d8cf6a4ef9ca.tar.bz2
Get the latest ParseFTPList code from Mozilla, and apply only the absolutely
required changes. This way future merging would be much easier. TEST=none BUG=none Review URL: http://codereview.chromium.org/201034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request')
-rw-r--r--net/url_request/url_request_new_ftp_job.cc29
-rw-r--r--net/url_request/url_request_new_ftp_job.h4
2 files changed, 22 insertions, 11 deletions
diff --git a/net/url_request/url_request_new_ftp_job.cc b/net/url_request/url_request_new_ftp_job.cc
index 231e654..40b23c4 100644
--- a/net/url_request/url_request_new_ftp_job.cc
+++ b/net/url_request/url_request_new_ftp_job.cc
@@ -245,27 +245,36 @@ int URLRequestNewFtpJob::ProcessFtpDir(net::IOBuffer *buf,
int64 file_size;
std::istringstream iss(std::string(buf->data(), bytes_read));
- struct net::ListState state;
+ struct net::list_state state;
memset(&state, 0, sizeof(state));
while (getline(iss, line)) {
- struct net::ListResult result;
+ struct net::list_result result;
std::replace(line.begin(), line.end(), '\r', '\0');
- net::LineType line_type = ParseFTPLine(line.c_str(), &state, &result);
+ int line_type = net::ParseFTPList(line.c_str(), &state, &result);
+
+ // The original code assumed months are in range 0-11 (PRExplodedTime),
+ // but our Time class expects a 1-12 range. Adjust it here, because
+ // the third-party parsing code uses bit-shifting on the month,
+ // and it'd be too easy to break that logic.
+ result.fe_time.month++;
+ DCHECK_LE(1, result.fe_time.month);
+ DCHECK_GE(12, result.fe_time.month);
+
switch (line_type) {
- case net::FTP_TYPE_DIRECTORY:
+ case 'd': // Directory entry.
file_entry.append(net::GetDirectoryListingEntry(
RawByteSequenceToFilename(result.fe_fname, encoding_),
result.fe_fname, true, 0,
base::Time::FromLocalExploded(result.fe_time)));
break;
- case net::FTP_TYPE_FILE:
+ case 'f': // File entry.
if (StringToInt64(result.fe_size, &file_size))
file_entry.append(net::GetDirectoryListingEntry(
RawByteSequenceToFilename(result.fe_fname, encoding_),
result.fe_fname, false, file_size,
base::Time::FromLocalExploded(result.fe_time)));
break;
- case net::FTP_TYPE_SYMLINK: {
+ case 'l': { // Symlink entry.
std::string filename(result.fe_fname, result.fe_fnlen);
// Parsers for styles 'U' and 'W' handle " -> " themselves.
@@ -283,10 +292,11 @@ int URLRequestNewFtpJob::ProcessFtpDir(net::IOBuffer *buf,
}
}
break;
- case net::FTP_TYPE_JUNK:
- case net::FTP_TYPE_COMMENT:
+ case '?': // Junk entry.
+ case '"': // Comment entry.
break;
default:
+ NOTREACHED();
break;
}
}
@@ -301,7 +311,8 @@ int URLRequestNewFtpJob::ProcessFtpDir(net::IOBuffer *buf,
return bytes_to_copy;
}
-void URLRequestNewFtpJob::LogFtpServerType(const net::ListState& list_state) {
+void URLRequestNewFtpJob::LogFtpServerType(
+ const struct net::list_state& list_state) {
// We can't recognize server type based on empty directory listings. Don't log
// that as unknown, it's misleading.
if (!list_state.parsed_one)
diff --git a/net/url_request/url_request_new_ftp_job.h b/net/url_request/url_request_new_ftp_job.h
index 2a66098..fade74d 100644
--- a/net/url_request/url_request_new_ftp_job.h
+++ b/net/url_request/url_request_new_ftp_job.h
@@ -16,7 +16,7 @@
class URLRequestContext;
namespace net {
-struct ListState;
+struct list_state;
}
// A URLRequestJob subclass that is built on top of FtpTransaction. It
@@ -56,7 +56,7 @@ class URLRequestNewFtpJob : public URLRequestJob {
int ProcessFtpDir(net::IOBuffer *buf, int buf_size, int bytes_read);
- void LogFtpServerType(const net::ListState& list_state);
+ void LogFtpServerType(const struct net::list_state& list_state);
net::FtpRequestInfo request_info_;
scoped_ptr<net::FtpTransaction> transaction_;