diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 09:20:48 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 09:20:48 +0000 |
commit | f5aba662bd2a0a85f1071d621f9dfa88485872b2 (patch) | |
tree | 73fa0c12b307b49e02597eae3a133392bcfe325e | |
parent | 543b18afcaa226282e0c67ad3fdf60f8f1933704 (diff) | |
download | chromium_src-f5aba662bd2a0a85f1071d621f9dfa88485872b2.zip chromium_src-f5aba662bd2a0a85f1071d621f9dfa88485872b2.tar.gz chromium_src-f5aba662bd2a0a85f1071d621f9dfa88485872b2.tar.bz2 |
Fix the "ls -l" FTP LIST format parser to understand correctly
listings sent by VMS MultiNet servers emulating Unix.
TEST=Covered by net_unittests.
BUG=22193, 25520
Review URL: http://codereview.chromium.org/368006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31217 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/data/ftp/dir-listing-ls-3 | 7 | ||||
-rw-r--r-- | net/data/ftp/dir-listing-ls-3.expected | 53 | ||||
-rw-r--r-- | net/data/ftp/dir-listing-ls-4 | 10 | ||||
-rw-r--r-- | net/data/ftp/dir-listing-ls-4.expected | 80 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_buffer_unittest.cc | 2 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parsers.cc | 10 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parsers.h | 2 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parsers_unittest.cc | 1 |
8 files changed, 163 insertions, 2 deletions
diff --git a/net/data/ftp/dir-listing-ls-3 b/net/data/ftp/dir-listing-ls-3 new file mode 100644 index 0000000..8720c06 --- /dev/null +++ b/net/data/ftp/dir-listing-ls-3 @@ -0,0 +1,7 @@ + +-r-xr-xr-x 1 anonymou 245 90 Mar 1 2003 .welcome +drwxr-xr-x 1 system 1 512 Feb 26 2005 decus +dr-xr-xr-x 1 system 1 3072 Dec 2 2006 gnv +-r-xr-xr-x 1 anonymou 245 158208 Apr 10 2003 unzip.alpha_exe +-r-xr-xr-x 1 anonymou 245 102400 Apr 10 2003 unzip.vax_exe +dr-xr-xr-x 1 anonymou 245 1024 Mar 1 2003 vms-freeware diff --git a/net/data/ftp/dir-listing-ls-3.expected b/net/data/ftp/dir-listing-ls-3.expected new file mode 100644 index 0000000..37bbbaf --- /dev/null +++ b/net/data/ftp/dir-listing-ls-3.expected @@ -0,0 +1,53 @@ +- +.welcome +90 +2003 +3 +1 +0 +0 + +d +decus +-1 +2005 +2 +26 +0 +0 + +d +gnv +-1 +2006 +12 +2 +0 +0 + +- +unzip.alpha_exe +158208 +2003 +4 +10 +0 +0 + +- +unzip.vax_exe +102400 +2003 +4 +10 +0 +0 + +d +vms-freeware +-1 +2003 +3 +1 +0 +0 diff --git a/net/data/ftp/dir-listing-ls-4 b/net/data/ftp/dir-listing-ls-4 new file mode 100644 index 0000000..078542f --- /dev/null +++ b/net/data/ftp/dir-listing-ls-4 @@ -0,0 +1,10 @@ + +-rwx---r-x 1 archives 0 472 Jun 28 2004 .welcome +drwxr-xr-x 1 archives 0 512 Mar 5 1998 contributed-software +drwxr-xr-x 1 archives 0 512 Nov 11 1997 customer_support +drwxr-xr-x 1 archives 0 512 Dec 30 1998 docs +drwxr-xr-x 1 archives 0 512 May 8 1998 faq +drwxr-xr-x 1 archives 0 512 Nov 11 1997 mail_archives +drwxr-xr-x 1 archives 0 1024 Nov 11 1997 patches +drwxr-xr-x 1 archives 0 512 Nov 11 1997 tech-tips +drwxr-xr-x 1 archives 0 512 Nov 11 1997 white_papers diff --git a/net/data/ftp/dir-listing-ls-4.expected b/net/data/ftp/dir-listing-ls-4.expected new file mode 100644 index 0000000..5339703 --- /dev/null +++ b/net/data/ftp/dir-listing-ls-4.expected @@ -0,0 +1,80 @@ +- +.welcome +472 +2004 +6 +28 +0 +0 + +d +contributed-software +-1 +1998 +3 +5 +0 +0 + +d +customer_support +-1 +1997 +11 +11 +0 +0 + +d +docs +-1 +1998 +12 +30 +0 +0 + +d +faq +-1 +1998 +5 +8 +0 +0 + +d +mail_archives +-1 +1997 +11 +11 +0 +0 + +d +patches +-1 +1997 +11 +11 +0 +0 + +d +tech-tips +-1 +1997 +11 +11 +0 +0 + +d +white_papers +-1 +1997 +11 +11 +0 +0 diff --git a/net/ftp/ftp_directory_listing_buffer_unittest.cc b/net/ftp/ftp_directory_listing_buffer_unittest.cc index ae448fb..00c37963 100644 --- a/net/ftp/ftp_directory_listing_buffer_unittest.cc +++ b/net/ftp/ftp_directory_listing_buffer_unittest.cc @@ -19,6 +19,8 @@ TEST(FtpDirectoryListingBufferTest, Parse) { "dir-listing-ls-1", "dir-listing-ls-1-utf8", "dir-listing-ls-2", + "dir-listing-ls-3", + "dir-listing-ls-4", "dir-listing-vms-1", "dir-listing-vms-2", "dir-listing-vms-3", diff --git a/net/ftp/ftp_directory_listing_parsers.cc b/net/ftp/ftp_directory_listing_parsers.cc index 5f160e3..4149390 100644 --- a/net/ftp/ftp_directory_listing_parsers.cc +++ b/net/ftp/ftp_directory_listing_parsers.cc @@ -236,10 +236,18 @@ namespace net { FtpDirectoryListingParser::~FtpDirectoryListingParser() { } -FtpLsDirectoryListingParser::FtpLsDirectoryListingParser() { +FtpLsDirectoryListingParser::FtpLsDirectoryListingParser() + : received_nonempty_line_(false) { } bool FtpLsDirectoryListingParser::ConsumeLine(const string16& 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() && !received_nonempty_line_) + return true; + received_nonempty_line_ = true; + std::vector<string16> columns; SplitString(CollapseWhitespace(line, false), ' ', &columns); if (columns.size() == 11) { diff --git a/net/ftp/ftp_directory_listing_parsers.h b/net/ftp/ftp_directory_listing_parsers.h index 230c641..2cf0c4f 100644 --- a/net/ftp/ftp_directory_listing_parsers.h +++ b/net/ftp/ftp_directory_listing_parsers.h @@ -55,6 +55,8 @@ class FtpLsDirectoryListingParser : public FtpDirectoryListingParser { virtual FtpDirectoryListingEntry PopEntry(); private: + bool received_nonempty_line_; + std::queue<FtpDirectoryListingEntry> entries_; DISALLOW_COPY_AND_ASSIGN(FtpLsDirectoryListingParser); diff --git a/net/ftp/ftp_directory_listing_parsers_unittest.cc b/net/ftp/ftp_directory_listing_parsers_unittest.cc index cc05f36..0d0c1f5 100644 --- a/net/ftp/ftp_directory_listing_parsers_unittest.cc +++ b/net/ftp/ftp_directory_listing_parsers_unittest.cc @@ -76,7 +76,6 @@ TEST_F(FtpDirectoryListingParsersTest, Ls) { } const char* bad_cases[] = { - "", "garbage", "-rw-r--r-- 1 ftp ftp", "-rw-r--rgb 1 ftp ftp 528 Nov 01 2007 README", |