diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-01 07:17:55 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-01 07:17:55 +0000 |
commit | 09262e2683fb3570780aba992d7129d809561846 (patch) | |
tree | 5dfe02907e21396872285e4c5ece494f2ff2d15d /net/ftp | |
parent | 2d4a530215dcc1d9d623fa3249038bd424c3a6cc (diff) | |
download | chromium_src-09262e2683fb3570780aba992d7129d809561846.zip chromium_src-09262e2683fb3570780aba992d7129d809561846.tar.gz chromium_src-09262e2683fb3570780aba992d7129d809561846.tar.bz2 |
FTP: fix directory listing parser when server fails to separate the first two columns.
BUG=70394
TEST=net_unittests
Review URL: http://codereview.chromium.org/6396005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73261 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp')
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_ls.cc | 7 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_ls_unittest.cc | 8 |
2 files changed, 11 insertions, 4 deletions
diff --git a/net/ftp/ftp_directory_listing_parser_ls.cc b/net/ftp/ftp_directory_listing_parser_ls.cc index 34ef519..fcb222f 100644 --- a/net/ftp/ftp_directory_listing_parser_ls.cc +++ b/net/ftp/ftp_directory_listing_parser_ls.cc @@ -39,10 +39,13 @@ bool LooksLikeUnixPermissionsListing(const string16& text) { text[0] != '-') return false; + // Do not check the rest of the string. Some servers fail to properly + // separate this column from the next column (number of links), resulting + // in additional characters at the end. Also, sometimes there is a "+" + // sign at the end indicating the file has ACLs set. return (LooksLikeUnixPermission(text.substr(1, 3)) && LooksLikeUnixPermission(text.substr(4, 3)) && - LooksLikeUnixPermission(text.substr(7, 3)) && - (text.substr(10).empty() || text.substr(10) == ASCIIToUTF16("+"))); + LooksLikeUnixPermission(text.substr(7, 3))); } bool LooksLikePermissionDeniedError(const string16& text) { diff --git a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc index ea4f094..88bbecd 100644 --- a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc +++ b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc @@ -81,6 +81,12 @@ TEST_F(FtpDirectoryListingParserLsTest, Good) { { "-rw-r--r-- 1 ftpadmin ftpadmin125435904 Apr 9 2008 .pureftpd-upload", net::FtpDirectoryListingEntry::FILE, ".pureftpd-upload", 0, 2008, 4, 9, 0, 0 }, + + // Tests for "ls -l" style listing with number of links + // not separated from permission listing (http://crbug.com/70394). + { "drwxr-xr-x1732 266 111 90112 Jun 21 2001 .rda_2", + net::FtpDirectoryListingEntry::DIRECTORY, ".rda_2", -1, + 2001, 6, 21, 0, 0 }, }; for (size_t i = 0; i < arraysize(good_cases); i++) { SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, @@ -134,8 +140,6 @@ TEST_F(FtpDirectoryListingParserLsTest, Bad) { "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README", "drwxrwxrwx 1 owner group 0 Sep 13 0:3 audio", - "d-wx-wx-wt++ 4 ftp 989 512 Dec 8 15:54 incoming", - "d-wx-wx-wt$ 4 ftp 989 512 Dec 8 15:54 incoming", "-qqqqqqqqq+ 2 sys 512 Mar 27 2009 pub", }; for (size_t i = 0; i < arraysize(bad_cases); i++) { |