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

Unified Diff: net/ftp/ftp_directory_listing_parser_ls.cc

Issue 10068016: FTP: make the code handling server messages in directory listings more general. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « net/data/ftp/dir-listing-ls-29.expected ('k') | net/ftp/ftp_directory_listing_parser_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_directory_listing_parser_ls.cc
===================================================================
--- net/ftp/ftp_directory_listing_parser_ls.cc (revision 131350)
+++ net/ftp/ftp_directory_listing_parser_ls.cc (working copy)
@@ -51,21 +51,6 @@
LooksLikeUnixPermission(text.substr(4, 3)));
}
-bool LooksLikePermissionDeniedError(const string16& text) {
- // Try to recognize a three-part colon-separated error message:
- //
- // 1. ftpd server name
- // 2. directory name (often just ".")
- // 3. message text (usually "Permission denied")
- std::vector<string16> parts;
- base::SplitString(CollapseWhitespace(text, false), ':', &parts);
-
- if (parts.size() != 3)
- return false;
-
- return parts[2].find(ASCIIToUTF16("Permission denied")) != string16::npos;
-}
-
// Returns the column index of the end of the date listing and detected
// last modification time.
bool DetectColumnOffsetAndModificationTime(const std::vector<string16>& columns,
@@ -159,10 +144,11 @@
current_time,
&column_offset,
&entry.last_modified)) {
- // If we can't recognize a normal listing line, maybe it's an error?
- // In that case, just ignore the error, but still recognize the data
- // as valid listing.
- if (LooksLikePermissionDeniedError(lines[i]))
+ // Some servers send a message in on of the first few lines.
eroman 2012/04/13 18:37:26 nit: "in on of the" --> "in one of the".
Paweł Hajdan Jr. 2012/04/14 10:12:14 Done.
+ // All those messages have in common is the string ".:",
+ // where "." means the current directory, and ":" separates it
+ // from the rest of the message, which may be empty.
+ if (lines[i].find(ASCIIToUTF16(".:")) != string16::npos)
gavinp 2012/04/12 18:03:14 LGTM. Initially I thought this was going to not a
Paweł Hajdan Jr. 2012/04/13 16:02:34 This is parser of "ls -l" format. We have other fo
continue;
return false;
« no previous file with comments | « net/data/ftp/dir-listing-ls-29.expected ('k') | net/ftp/ftp_directory_listing_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698