diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 07:49:36 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 07:49:36 +0000 |
commit | 27477a9f30776550ac1264d65f8f2a69984b32d0 (patch) | |
tree | 03f7c3de15481a599dd5200379f8ed1e4c83f55f /net | |
parent | 7dbfefe01d85c8cc6c34d4d04a96029bf2c5ddfa (diff) | |
download | chromium_src-27477a9f30776550ac1264d65f8f2a69984b32d0.zip chromium_src-27477a9f30776550ac1264d65f8f2a69984b32d0.tar.gz chromium_src-27477a9f30776550ac1264d65f8f2a69984b32d0.tar.bz2 |
Compatibility updates for "ls -l" style FTP LIST response parser:
- recognize permission listing with ACL indicator as valid
- add one more test for non-ASCII encoding
TEST=Covered by net_unittests.
BUG=25520
Review URL: http://codereview.chromium.org/472003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34240 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/data/ftp/dir-listing-ls-15 | 5 | ||||
-rw-r--r-- | net/data/ftp/dir-listing-ls-15.expected | 35 | ||||
-rw-r--r-- | net/data/ftp/dir-listing-ls-16 | 7 | ||||
-rw-r--r-- | net/data/ftp/dir-listing-ls-16.expected | 62 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_buffer_unittest.cc | 2 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_ls.cc | 5 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_ls_unittest.cc | 7 |
7 files changed, 121 insertions, 2 deletions
diff --git a/net/data/ftp/dir-listing-ls-15 b/net/data/ftp/dir-listing-ls-15 new file mode 100644 index 0000000..ee0de6f --- /dev/null +++ b/net/data/ftp/dir-listing-ls-15 @@ -0,0 +1,5 @@ +total 30 +---------- 1 root other 0 Mar 26 2004 .notar +d-wx-wx-wt+ 4 ftp 989 512 Dec 8 15:54 incoming +-r--r--r-- 2 ftp 989 7196 Aug 22 2007 incoming.README +drwxr-xr-x+ 16 root sys 512 Sep 25 09:56 pub diff --git a/net/data/ftp/dir-listing-ls-15.expected b/net/data/ftp/dir-listing-ls-15.expected new file mode 100644 index 0000000..fd064ad --- /dev/null +++ b/net/data/ftp/dir-listing-ls-15.expected @@ -0,0 +1,35 @@ +- +.notar +0 +2004 +3 +26 +0 +0 + +d +incoming +-1 +current +12 +8 +15 +54 + +- +incoming.README +7196 +2007 +8 +22 +0 +0 + +d +pub +-1 +current +9 +25 +9 +56 diff --git a/net/data/ftp/dir-listing-ls-16 b/net/data/ftp/dir-listing-ls-16 new file mode 100644 index 0000000..4c2f783 --- /dev/null +++ b/net/data/ftp/dir-listing-ls-16 @@ -0,0 +1,7 @@ +dr-xr-xr-x 1 owner group 0 Nov 28 2008 documentales +dr-xr-xr-x 1 owner group 0 Nov 28 2008 dosier +dr-xr-xr-x 1 owner group 0 Dec 1 2008 promos +dr-xr-xr-x 1 owner group 0 Nov 28 2008 Sueños_futbol +dr-xr-xr-x 1 owner group 0 Nov 2 15:53 test +dr-xr-xr-x 1 owner group 0 Nov 25 10:04 tmp +-r-xr-xr-x 1 owner group 125 Oct 11 2007 Gastronomía.txt diff --git a/net/data/ftp/dir-listing-ls-16.expected b/net/data/ftp/dir-listing-ls-16.expected new file mode 100644 index 0000000..6a8fa74 --- /dev/null +++ b/net/data/ftp/dir-listing-ls-16.expected @@ -0,0 +1,62 @@ +d +documentales +-1 +2008 +11 +28 +0 +0 + +d +dosier +-1 +2008 +11 +28 +0 +0 + +d +promos +-1 +2008 +12 +1 +0 +0 + +d +Sueños_futbol +-1 +2008 +11 +28 +0 +0 + +d +test +-1 +current +11 +2 +15 +53 + +d +tmp +-1 +current +11 +25 +10 +4 + +- +GastronomÃa.txt +125 +2007 +10 +11 +0 +0 diff --git a/net/ftp/ftp_directory_listing_buffer_unittest.cc b/net/ftp/ftp_directory_listing_buffer_unittest.cc index 1f739cf..b9ca7a2 100644 --- a/net/ftp/ftp_directory_listing_buffer_unittest.cc +++ b/net/ftp/ftp_directory_listing_buffer_unittest.cc @@ -32,6 +32,8 @@ TEST(FtpDirectoryListingBufferTest, Parse) { "dir-listing-ls-12", "dir-listing-ls-13", "dir-listing-ls-14", + "dir-listing-ls-15", + "dir-listing-ls-16", "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 f5136db..c7c4326 100644 --- a/net/ftp/ftp_directory_listing_parser_ls.cc +++ b/net/ftp/ftp_directory_listing_parser_ls.cc @@ -28,7 +28,7 @@ bool LooksLikeUnixPermission(const string16& text) { } bool LooksLikeUnixPermissionsListing(const string16& text) { - if (text.length() != 10) + if (text.length() < 10) return false; if (text[0] != 'b' && text[0] != 'c' && text[0] != 'd' && @@ -38,7 +38,8 @@ bool LooksLikeUnixPermissionsListing(const string16& text) { return (LooksLikeUnixPermission(text.substr(1, 3)) && LooksLikeUnixPermission(text.substr(4, 3)) && - LooksLikeUnixPermission(text.substr(7, 3))); + LooksLikeUnixPermission(text.substr(7, 3)) && + (text.substr(10).empty() || text.substr(10) == ASCIIToUTF16("+"))); } string16 GetStringPartAfterColumns(const string16& text, int columns) { diff --git a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc index 4107f9f..ad7edc1 100644 --- a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc +++ b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc @@ -40,6 +40,9 @@ TEST_F(FtpDirectoryListingParserLsTest, Good) { { "-rw-r--r-- 1 2 3 3447432 May 18 2009 Foo - Manual.pdf", net::FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432, 2009, 5, 18, 0, 0 }, + { "d-wx-wx-wt+ 4 ftp 989 512 Dec 8 15:54 incoming", + net::FtpDirectoryListingEntry::DIRECTORY, "incoming", -1, + now_exploded.year, 12, 8, 15, 54 }, // Tests for the wu-ftpd variant: { "drwxr-xr-x 2 sys 512 Mar 27 2009 pub", @@ -92,6 +95,10 @@ TEST_F(FtpDirectoryListingParserLsTest, Bad) { "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README", "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README", + "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", + // Tests important for security: verify that after we detect the column // offset we don't try to access invalid memory on malformed input. "drwxr-xr-x 3 ftp ftp 4096 May 15 18:11", |