summaryrefslogtreecommitdiffstats
path: root/net/ftp
diff options
context:
space:
mode:
Diffstat (limited to 'net/ftp')
-rw-r--r--net/ftp/ftp_directory_listing_parser_ls.cc9
-rw-r--r--net/ftp/ftp_directory_listing_parser_ls_unittest.cc5
2 files changed, 10 insertions, 4 deletions
diff --git a/net/ftp/ftp_directory_listing_parser_ls.cc b/net/ftp/ftp_directory_listing_parser_ls.cc
index ec99700..5c2e4e9 100644
--- a/net/ftp/ftp_directory_listing_parser_ls.cc
+++ b/net/ftp/ftp_directory_listing_parser_ls.cc
@@ -187,8 +187,13 @@ bool ParseFtpDirectoryListingLs(
// TODO(phajdan.jr): Use a value that means "unknown" instead of 0 bytes.
entry.size = 0;
}
- if (entry.size < 0)
- return false;
+ if (entry.size < 0) {
+ // Some FTP servers have bugs that cause them to display the file size
+ // as negative. They're most likely big files like DVD ISO images.
+ // We still want to display them, so just say the real file size
+ // is unknown.
+ entry.size = -1;
+ }
if (entry.type != FtpDirectoryListingEntry::FILE)
entry.size = -1;
diff --git a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc
index 4779a3c..b14d5c0 100644
--- a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc
+++ b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc
@@ -50,6 +50,9 @@ TEST_F(FtpDirectoryListingParserLsTest, Good) {
{ "lrwxrwxrwx 1 0 0 26 Sep 18 2008 pub",
FtpDirectoryListingEntry::SYMLINK, "pub", -1,
2008, 9, 18, 0, 0 },
+ { "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README",
+ FtpDirectoryListingEntry::FILE, "README", -1,
+ 2007, 11, 1, 0, 0 },
// Tests for the wu-ftpd variant:
{ "drwxr-xr-x 2 sys 512 Mar 27 2009 pub",
@@ -161,12 +164,10 @@ TEST_F(FtpDirectoryListingParserLsTest, Bad) {
"-rw-r--r-- ftp ftp",
"-rw-rgbr-- ftp ftp 528 Nov 01 2007 README",
"qrwwr--r-- ftp ftp 528 Nov 01 2007 README",
- "-rw-r--r-- ftp ftp -528 Nov 01 2007 README",
"-rw-r--r-- ftp ftp 528 Foo 01 2007 README",
"-rw-r--r-- 1 ftp ftp",
"-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README",
"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 1024 Sep 13 0:3 audio",