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

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

Issue 6515009: FTP: Compatibility fix for "ls -l" style directory listing parser.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_ls.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/ftp/ftp_directory_listing_parser_ls.h" 5 #include "net/ftp/ftp_directory_listing_parser_ls.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Unrecognized listing style. 95 // Unrecognized listing style.
96 return false; 96 return false;
97 } 97 }
98 98
99 } // namespace 99 } // namespace
100 100
101 namespace net { 101 namespace net {
102 102
103 FtpDirectoryListingParserLs::FtpDirectoryListingParserLs( 103 FtpDirectoryListingParserLs::FtpDirectoryListingParserLs(
104 const base::Time& current_time) 104 const base::Time& current_time)
105 : received_nonempty_line_(false), 105 : received_total_line_(false),
106 received_total_line_(false),
107 current_time_(current_time) { 106 current_time_(current_time) {
108 } 107 }
109 108
110 FtpDirectoryListingParserLs::~FtpDirectoryListingParserLs() {} 109 FtpDirectoryListingParserLs::~FtpDirectoryListingParserLs() {}
111 110
112 FtpServerType FtpDirectoryListingParserLs::GetServerType() const { 111 FtpServerType FtpDirectoryListingParserLs::GetServerType() const {
113 return SERVER_LS; 112 return SERVER_LS;
114 } 113 }
115 114
116 bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) { 115 bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) {
117 if (line.empty() && !received_nonempty_line_) { 116 if (line.empty())
118 // Allow empty lines only at the beginning of the listing. For example VMS
119 // systems in Unix emulation mode add an empty line before the first listing
120 // entry.
121 return true; 117 return true;
122 }
123 received_nonempty_line_ = true;
124 118
125 std::vector<string16> columns; 119 std::vector<string16> columns;
126 base::SplitString(CollapseWhitespace(line, false), ' ', &columns); 120 base::SplitString(CollapseWhitespace(line, false), ' ', &columns);
127 121
128 // Some FTP servers put a "total n" line at the beginning of the listing 122 // Some FTP servers put a "total n" line at the beginning of the listing
129 // (n is an integer). Allow such a line, but only once, and only if it's 123 // (n is an integer). Allow such a line, but only once, and only if it's
130 // the first non-empty line. Do not match the word exactly, because it may be 124 // the first non-empty line. Do not match the word exactly, because it may be
131 // in different languages (at least English and German have been seen in the 125 // in different languages (at least English and German have been seen in the
132 // field). 126 // field).
133 if (columns.size() == 2 && !received_total_line_) { 127 if (columns.size() == 2 && !received_total_line_) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 return !entries_.empty(); 226 return !entries_.empty();
233 } 227 }
234 228
235 FtpDirectoryListingEntry FtpDirectoryListingParserLs::PopEntry() { 229 FtpDirectoryListingEntry FtpDirectoryListingParserLs::PopEntry() {
236 FtpDirectoryListingEntry entry = entries_.front(); 230 FtpDirectoryListingEntry entry = entries_.front();
237 entries_.pop(); 231 entries_.pop();
238 return entry; 232 return entry;
239 } 233 }
240 234
241 } // namespace net 235 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_ls.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698