diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-14 18:44:59 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-14 18:44:59 +0000 |
commit | 3ce597fc42a1cb4914f9e5396708167987e669d7 (patch) | |
tree | 5a4058b2ef213d2f44e6fd8b0db8c4e30e922a61 /net | |
parent | 85bbc6e2f370be457537ea552a8fe694f609960a (diff) | |
download | chromium_src-3ce597fc42a1cb4914f9e5396708167987e669d7.zip chromium_src-3ce597fc42a1cb4914f9e5396708167987e669d7.tar.gz chromium_src-3ce597fc42a1cb4914f9e5396708167987e669d7.tar.bz2 |
FTP: fix parsing error on ftp.dell.com
The problem was the date parser not recognizing time strings like H:MM as valid.
Additionally, make sure the message about the error is visible.
BUG=54395
TEST=visit ftp.dell.com, you should see a non-empty directory listing
Review URL: http://codereview.chromium.org/3327025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59404 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/dir_header.html | 2 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_ls_unittest.cc | 4 | ||||
-rw-r--r-- | net/ftp/ftp_util.cc | 24 |
3 files changed, 21 insertions, 9 deletions
diff --git a/net/base/dir_header.html b/net/base/dir_header.html index ad4ec0a..4f33bba 100644 --- a/net/base/dir_header.html +++ b/net/base/dir_header.html @@ -62,7 +62,7 @@ function onListingParsingError() { var box = document.getElementById("listingParsingErrorBox"); box.innerHTML = box.innerHTML.replace("LOCATION", encodeURI(document.location) + "?raw"); - box.style.display = ""; + box.style.display = "block"; } </script> diff --git a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc index 608e0e2..c67c928 100644 --- a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc +++ b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc @@ -45,6 +45,9 @@ TEST_F(FtpDirectoryListingParserLsTest, Good) { { "d-wx-wx-wt+ 4 ftp 989 512 Dec 8 15:54 incoming", net::FtpDirectoryListingEntry::DIRECTORY, "incoming", -1, 1993, 12, 8, 15, 54 }, + { "drwxrwxrwx 1 owner group 0 Sep 13 0:30 audio", + net::FtpDirectoryListingEntry::DIRECTORY, "audio", -1, + 1994, 9, 13, 0, 30 }, // Tests for the wu-ftpd variant: { "drwxr-xr-x 2 sys 512 Mar 27 2009 pub", @@ -100,6 +103,7 @@ TEST_F(FtpDirectoryListingParserLsTest, Bad) { "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README", "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README", "-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", diff --git a/net/ftp/ftp_util.cc b/net/ftp/ftp_util.cc index 269a063..aeb2355 100644 --- a/net/ftp/ftp_util.cc +++ b/net/ftp/ftp_util.cc @@ -160,15 +160,23 @@ bool FtpUtil::LsDateListingToTime(const string16& month, const string16& day, return false; if (!base::StringToInt(rest, &time_exploded.year)) { - // Maybe it's time. Does it look like time (MM:HH)? - if (rest.length() != 5 || rest[2] != ':') - return false; - - if (!base::StringToInt(rest.substr(0, 2), &time_exploded.hour)) - return false; - - if (!base::StringToInt(rest.substr(3, 2), &time_exploded.minute)) + // Maybe it's time. Does it look like time (HH:MM)? + if (rest.length() == 5 && rest[2] == ':') { + if (!base::StringToInt(rest.substr(0, 2), &time_exploded.hour)) + return false; + + if (!base::StringToInt(rest.substr(3, 2), &time_exploded.minute)) + return false; + } else if (rest.length() == 4 && rest[1] == ':') { + // Sometimes it's just H:MM. + if (!base::StringToInt(rest.substr(0, 1), &time_exploded.hour)) + return false; + + if (!base::StringToInt(rest.substr(2, 2), &time_exploded.minute)) + return false; + } else { return false; + } // Guess the year. base::Time::Exploded current_exploded; |