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

Unified Diff: net/ftp/ftp_directory_listing_parser_ls.cc

Issue 4182002: FTP: fix directory listing parser for ftp://ftp.dd-wrt.com/others/juno6/ (Closed)
Patch Set: typo Created 10 years, 2 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/ftp/ftp_directory_listing_parser_ls.cc
diff --git a/net/ftp/ftp_directory_listing_parser_ls.cc b/net/ftp/ftp_directory_listing_parser_ls.cc
index 89fc3d83d2bc80e4e1db50e208c3244b6a88dc6c..58a9bb9fb8e8514ea3a7ba900803262791db8f53 100644
--- a/net/ftp/ftp_directory_listing_parser_ls.cc
+++ b/net/ftp/ftp_directory_listing_parser_ls.cc
@@ -127,7 +127,7 @@ bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) {
// We may receive file names containing spaces, which can make the number of
// columns arbitrarily large. We will handle that later. For now just make
// sure we have all the columns that should normally be there.
- if (columns.size() < 7U + column_offset)
+ if (columns.size() < 6U + column_offset)
wtc 2010/10/28 01:05:41 It would be nice to document what are the 6 column
Paweł Hajdan Jr. 2010/10/28 07:15:34 Good idea, done.
return false;
if (!LooksLikeUnixPermissionsListing(columns[0]))
@@ -165,6 +165,14 @@ bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) {
}
entry.name = FtpUtil::GetStringPartAfterColumns(line, 6 + column_offset);
+
+ if (entry.name.empty()) {
+ // Some FTP servers send listing entries with empty names. It's not obvious
+ // how to display such an entry, so we ignore them. We don't want to make
+ // the parsing fail at this point though. Other entries can still be useful.
+ return true;
+ }
+
if (entry.type == FtpDirectoryListingEntry::SYMLINK) {
string16::size_type pos = entry.name.rfind(ASCIIToUTF16(" -> "));

Powered by Google App Engine
This is Rietveld 408576698