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

Side by Side Diff: net/ftp/ftp_directory_listing_parsers.cc

Issue 368006: Fix the "ls -l" FTP LIST format parser to understand correctly (Closed)
Patch Set: make the code more obvious Created 11 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "net/ftp/ftp_directory_listing_parsers.h" 5 #include "net/ftp/ftp_directory_listing_parsers.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 8
9 namespace { 9 namespace {
10 10
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 return true; 229 return true;
230 } 230 }
231 231
232 } // namespace 232 } // namespace
233 233
234 namespace net { 234 namespace net {
235 235
236 FtpDirectoryListingParser::~FtpDirectoryListingParser() { 236 FtpDirectoryListingParser::~FtpDirectoryListingParser() {
237 } 237 }
238 238
239 FtpLsDirectoryListingParser::FtpLsDirectoryListingParser() { 239 FtpLsDirectoryListingParser::FtpLsDirectoryListingParser()
240 : received_nonempty_line_(false) {
240 } 241 }
241 242
242 bool FtpLsDirectoryListingParser::ConsumeLine(const string16& line) { 243 bool FtpLsDirectoryListingParser::ConsumeLine(const string16& line) {
244 // Allow empty lines only at the beginning of the listing. For example VMS
245 // systems in Unix emulation mode add an empty line before the first listing
246 // entry.
247 if (line.empty() && !received_nonempty_line_)
248 return true;
249 received_nonempty_line_ = true;
250
243 std::vector<string16> columns; 251 std::vector<string16> columns;
244 SplitString(CollapseWhitespace(line, false), ' ', &columns); 252 SplitString(CollapseWhitespace(line, false), ' ', &columns);
245 if (columns.size() == 11) { 253 if (columns.size() == 11) {
246 // Check if it is a symlink. 254 // Check if it is a symlink.
247 if (columns[9] != ASCIIToUTF16("->")) 255 if (columns[9] != ASCIIToUTF16("->"))
248 return false; 256 return false;
249 257
250 // Drop the symlink target from columns, we don't use it. 258 // Drop the symlink target from columns, we don't use it.
251 columns.resize(9); 259 columns.resize(9);
252 } 260 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 if (entry.type != FtpDirectoryListingEntry::FILE) 425 if (entry.type != FtpDirectoryListingEntry::FILE)
418 entry.size = -1; 426 entry.size = -1;
419 if (!VmsDateListingToTime(columns, &entry.last_modified)) 427 if (!VmsDateListingToTime(columns, &entry.last_modified))
420 return false; 428 return false;
421 429
422 entries_.push(entry); 430 entries_.push(entry);
423 return true; 431 return true;
424 } 432 }
425 433
426 } // namespace net 434 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parsers.h ('k') | net/ftp/ftp_directory_listing_parsers_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698