| 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 cc09ca0859992f5c019493576424777502254b48..f5136dbb6751ccc92362eace9b32babfca1da601 100644
|
| --- a/net/ftp/ftp_directory_listing_parser_ls.cc
|
| +++ b/net/ftp/ftp_directory_listing_parser_ls.cc
|
| @@ -64,7 +64,7 @@ bool DetectColumnOffset(const std::vector<string16>& columns, int* offset) {
|
| net::FtpUtil::LsDateListingToTime(columns[5], columns[6], columns[7],
|
| &time)) {
|
| // Standard listing, exactly like ls -l.
|
| - *offset = 1;
|
| + *offset = 2;
|
| return true;
|
| }
|
|
|
| @@ -72,6 +72,15 @@ bool DetectColumnOffset(const std::vector<string16>& columns, int* offset) {
|
| net::FtpUtil::LsDateListingToTime(columns[4], columns[5], columns[6],
|
| &time)) {
|
| // wu-ftpd listing, no "number of links" column.
|
| + *offset = 1;
|
| + return true;
|
| + }
|
| +
|
| + if (columns.size() >= 6 &&
|
| + net::FtpUtil::LsDateListingToTime(columns[3], columns[4], columns[5],
|
| + &time)) {
|
| + // Xplain FTP Server listing for folders, like this:
|
| + // drwxr-xr-x folder 0 Jul 17 2006 online
|
| *offset = 0;
|
| return true;
|
| }
|
| @@ -86,20 +95,21 @@ namespace net {
|
|
|
| FtpDirectoryListingParserLs::FtpDirectoryListingParserLs()
|
| : received_nonempty_line_(false),
|
| - received_total_line_(false),
|
| - column_offset_(-1) {
|
| + received_total_line_(false) {
|
| }
|
|
|
| bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) {
|
| - std::vector<string16> columns;
|
| - SplitString(CollapseWhitespace(line, false), ' ', &columns);
|
| -
|
| if (line.empty() && !received_nonempty_line_) {
|
| // Allow empty lines only at the beginning of the listing. For example VMS
|
| // systems in Unix emulation mode add an empty line before the first listing
|
| // entry.
|
| return true;
|
| }
|
| + received_nonempty_line_ = true;
|
| +
|
| + std::vector<string16> columns;
|
| + SplitString(CollapseWhitespace(line, false), ' ', &columns);
|
| +
|
| // Some FTP servers put a "total n" line at the beginning of the listing
|
| // (n is an integer). Allow such a line, but only once, and only if it's
|
| // the first non-empty line. Do not match the word exactly, because it may be
|
| @@ -116,14 +126,15 @@ bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) {
|
|
|
| return true;
|
| }
|
| - if (!received_nonempty_line_ && !DetectColumnOffset(columns, &column_offset_))
|
| +
|
| + int column_offset;
|
| + if (!DetectColumnOffset(columns, &column_offset))
|
| return false;
|
| - received_nonempty_line_ = true;
|
|
|
| // 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() < 8U + column_offset_)
|
| + if (columns.size() < 7U + column_offset)
|
| return false;
|
|
|
| if (!LooksLikeUnixPermissionsListing(columns[0]))
|
| @@ -138,21 +149,21 @@ bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) {
|
| entry.type = FtpDirectoryListingEntry::FILE;
|
| }
|
|
|
| - if (!StringToInt64(columns[3 + column_offset_], &entry.size))
|
| + if (!StringToInt64(columns[2 + column_offset], &entry.size))
|
| return false;
|
| if (entry.size < 0)
|
| return false;
|
| if (entry.type != FtpDirectoryListingEntry::FILE)
|
| entry.size = -1;
|
|
|
| - if (!FtpUtil::LsDateListingToTime(columns[4 + column_offset_],
|
| - columns[5 + column_offset_],
|
| - columns[6 + column_offset_],
|
| + if (!FtpUtil::LsDateListingToTime(columns[3 + column_offset],
|
| + columns[4 + column_offset],
|
| + columns[5 + column_offset],
|
| &entry.last_modified)) {
|
| return false;
|
| }
|
|
|
| - entry.name = GetStringPartAfterColumns(line, 7 + column_offset_);
|
| + entry.name = GetStringPartAfterColumns(line, 6 + column_offset);
|
| if (entry.type == FtpDirectoryListingEntry::SYMLINK) {
|
| string16::size_type pos = entry.name.rfind(ASCIIToUTF16(" -> "));
|
| if (pos == string16::npos)
|
|
|