Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(943)

Unified Diff: net/url_request/url_request_new_ftp_job.cc

Issue 201034: Get the latest ParseFTPList code from Mozilla, and apply only the absolutely (Closed)
Patch Set: kill NSPR comment Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/url_request/url_request_new_ftp_job.cc
diff --git a/net/url_request/url_request_new_ftp_job.cc b/net/url_request/url_request_new_ftp_job.cc
index 231e6540f82e64569fde17e7db4131fd213a4561..40b23c4df43b58265f60d2cb2920d81a82005f10 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,
wtc 2009/09/10 18:55:32 I now understand the bit-shifting code in ParseFTP
+ // 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)
« net/third_party/parseftp/chromium.patch ('K') | « net/url_request/url_request_new_ftp_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698