summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-16 07:39:55 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-16 07:39:55 +0000
commit86e9fe46687bf4b4d607e8b33a54d530e3d95c4e (patch)
tree510fcd427c192263844ddd159ec9f486a671c866
parent08f42e7193c00c18cb2bfb28aa1e4958c8e08fdd (diff)
downloadchromium_src-86e9fe46687bf4b4d607e8b33a54d530e3d95c4e.zip
chromium_src-86e9fe46687bf4b4d607e8b33a54d530e3d95c4e.tar.gz
chromium_src-86e9fe46687bf4b4d607e8b33a54d530e3d95c4e.tar.bz2
FTP: Compatibility fix for "ls -l" style directory listing parser.
Some servers, for example smallftpd, add an empty line at the end of the listing. We should not fail on those. I think this bug was introduced in 2009 by http://codereview.chromium.org/449011 Now we have more test cases, and this change shouldn't introduce new compatibility problems. BUG=72060 TEST=net_unittests Review URL: http://codereview.chromium.org/6515009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75079 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/data/ftp/dir-listing-ls-242
-rw-r--r--net/data/ftp/dir-listing-ls-24.expected8
-rw-r--r--net/ftp/ftp_directory_listing_buffer_unittest.cc1
-rw-r--r--net/ftp/ftp_directory_listing_parser_ls.cc10
-rw-r--r--net/ftp/ftp_directory_listing_parser_ls.h2
5 files changed, 13 insertions, 10 deletions
diff --git a/net/data/ftp/dir-listing-ls-24 b/net/data/ftp/dir-listing-ls-24
new file mode 100644
index 0000000..acb09a8
--- /dev/null
+++ b/net/data/ftp/dir-listing-ls-24
@@ -0,0 +1,2 @@
+drwxr-xr-x 33 ftp ftp 4096 Aug 12 2008 note_empty_line_below
+
diff --git a/net/data/ftp/dir-listing-ls-24.expected b/net/data/ftp/dir-listing-ls-24.expected
new file mode 100644
index 0000000..c46afa2
--- /dev/null
+++ b/net/data/ftp/dir-listing-ls-24.expected
@@ -0,0 +1,8 @@
+d
+note_empty_line_below
+-1
+2008
+8
+12
+0
+0
diff --git a/net/ftp/ftp_directory_listing_buffer_unittest.cc b/net/ftp/ftp_directory_listing_buffer_unittest.cc
index 81e72c1..4c71008 100644
--- a/net/ftp/ftp_directory_listing_buffer_unittest.cc
+++ b/net/ftp/ftp_directory_listing_buffer_unittest.cc
@@ -43,6 +43,7 @@ TEST(FtpDirectoryListingBufferTest, Parse) {
"dir-listing-ls-21", // TODO(phajdan.jr): should use windows-1251 encoding.
"dir-listing-ls-22", // TODO(phajdan.jr): should use windows-1251 encoding.
"dir-listing-ls-23",
+ "dir-listing-ls-24",
"dir-listing-netware-1",
"dir-listing-netware-2",
"dir-listing-vms-1",
diff --git a/net/ftp/ftp_directory_listing_parser_ls.cc b/net/ftp/ftp_directory_listing_parser_ls.cc
index fcb222f..d6d147a 100644
--- a/net/ftp/ftp_directory_listing_parser_ls.cc
+++ b/net/ftp/ftp_directory_listing_parser_ls.cc
@@ -102,8 +102,7 @@ namespace net {
FtpDirectoryListingParserLs::FtpDirectoryListingParserLs(
const base::Time& current_time)
- : received_nonempty_line_(false),
- received_total_line_(false),
+ : received_total_line_(false),
current_time_(current_time) {
}
@@ -114,13 +113,8 @@ FtpServerType FtpDirectoryListingParserLs::GetServerType() const {
}
bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) {
- 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.
+ if (line.empty())
return true;
- }
- received_nonempty_line_ = true;
std::vector<string16> columns;
base::SplitString(CollapseWhitespace(line, false), ' ', &columns);
diff --git a/net/ftp/ftp_directory_listing_parser_ls.h b/net/ftp/ftp_directory_listing_parser_ls.h
index 3004f70..49607092 100644
--- a/net/ftp/ftp_directory_listing_parser_ls.h
+++ b/net/ftp/ftp_directory_listing_parser_ls.h
@@ -30,8 +30,6 @@ class FtpDirectoryListingParserLs : public FtpDirectoryListingParser {
virtual FtpDirectoryListingEntry PopEntry();
private:
- bool received_nonempty_line_;
-
// True after we have received a "total n" listing header, where n is an
// integer. Only one such header is allowed per listing.
bool received_total_line_;