summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-04 17:49:34 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-04 17:49:34 +0000
commitbde1ca85915024b6a4c7e89a39b3545d058312ab (patch)
tree0938205dd4c5a2b34a9dae046278ac0aabfcf318
parent2097a5e33a01dd31a650a85be9e2484bcf6074c2 (diff)
downloadchromium_src-bde1ca85915024b6a4c7e89a39b3545d058312ab.zip
chromium_src-bde1ca85915024b6a4c7e89a39b3545d058312ab.tar.gz
chromium_src-bde1ca85915024b6a4c7e89a39b3545d058312ab.tar.bz2
FTP: misc fixes resulting from my testing.
- "total ..." lines can have values bigger than 32-bit - some servers use "l" as a flag in permission listing - some servers prepend garbage to the month column - NetWare directory listings can have spaces in file names - one additional variant of VMS error message BUG=none Review URL: https://codereview.chromium.org/11418296 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170996 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/data/ftp/dir-listing-ls-302
-rw-r--r--net/data/ftp/dir-listing-ls-30.expected8
-rw-r--r--net/data/ftp/dir-listing-netware-322
-rw-r--r--net/data/ftp/dir-listing-netware-3.expected188
-rw-r--r--net/ftp/ftp_directory_listing_parser_ls.cc11
-rw-r--r--net/ftp/ftp_directory_listing_parser_ls_unittest.cc12
-rw-r--r--net/ftp/ftp_directory_listing_parser_netware.cc4
-rw-r--r--net/ftp/ftp_directory_listing_parser_netware_unittest.cc3
-rw-r--r--net/ftp/ftp_directory_listing_parser_unittest.cc2
-rw-r--r--net/ftp/ftp_directory_listing_parser_vms.cc1
-rw-r--r--net/ftp/ftp_util.cc11
11 files changed, 255 insertions, 9 deletions
diff --git a/net/data/ftp/dir-listing-ls-30 b/net/data/ftp/dir-listing-ls-30
new file mode 100644
index 0000000..6c095cc
--- /dev/null
+++ b/net/data/ftp/dir-listing-ls-30
@@ -0,0 +1,2 @@
+total 395136991232
+drwx-wx-wx 10 ftpadmin ftpusers 256 May 27 2010 downloads
diff --git a/net/data/ftp/dir-listing-ls-30.expected b/net/data/ftp/dir-listing-ls-30.expected
new file mode 100644
index 0000000..19dcc75
--- /dev/null
+++ b/net/data/ftp/dir-listing-ls-30.expected
@@ -0,0 +1,8 @@
+d
+downloads
+-1
+2010
+5
+27
+0
+0
diff --git a/net/data/ftp/dir-listing-netware-3 b/net/data/ftp/dir-listing-netware-3
new file mode 100644
index 0000000..1d24bcc
--- /dev/null
+++ b/net/data/ftp/dir-listing-netware-3
@@ -0,0 +1,22 @@
+total 0
+- [RWCEAFMS] bodi 1588 Oct 28 22:21 leltar.as
+- [RWCEAFMS] bodi 19440 Oct 28 22:21 leltarVizellatas.as
+- [RWCEAFMS] bodi 38795 Oct 28 22:21 leltarVizelvezetes.as
+- [RWCEAFMS] bodi 227 Jan 06 2010 Olvass_el.txt
+- [RWCEAFMS] dora 19300888 Jan 15 2011 vegleges.pdf
+d [RWCEAFMS] Fulop 512 Nov 10 2011 DHI
+d [RWCEAFMS] bodi 512 Aug 02 11:48 English
+d [RWCEAFMS] clement 512 Jun 24 2011 Floodrisk
+d [RWCEAFMS] bodi 512 Mar 10 14:53 HC_MIR_FD
+d [RWCEAFMS] bodi 512 Oct 08 15:59 HCWP614-11
+d [RWCEAFMS] knolmar 512 Mar 26 15:10 Mike
+d [RWCEAFMS] daniel 512 May 17 2010 NVP anyagok
+d [RWCEAFMS] bodi 512 Sep 15 2010 Oktatas
+d [RWCEAFMS] buzas 512 Oct 09 12:47 processing_modflow
+d [RWCEAFMS] peterbud 512 Mar 24 2010 Prospektushoz
+d [RWCEAFMS] bodi 512 Sep 05 2011 sewcad
+d [RWCEAFMS] bodi 512 May 09 08:50 szakmernok
+d [RWCEAFMS] daniel 512 Aug 03 18:53 tomi
+d [RWCEAFMS] bodi 512 Sep 20 21:10 Virtualis-GEP
+d [RWCEAFMS] clement 512 Sep 26 12:31 Vizrajzi evkonyvek
+d [RWCEAFMS] darabos 512 Jul 09 2011 VKKI-Tanulmanyok
diff --git a/net/data/ftp/dir-listing-netware-3.expected b/net/data/ftp/dir-listing-netware-3.expected
new file mode 100644
index 0000000..fe809e3
--- /dev/null
+++ b/net/data/ftp/dir-listing-netware-3.expected
@@ -0,0 +1,188 @@
+-
+leltar.as
+1588
+1994
+10
+28
+22
+21
+
+-
+leltarVizellatas.as
+19440
+1994
+10
+28
+22
+21
+
+-
+leltarVizelvezetes.as
+38795
+1994
+10
+28
+22
+21
+
+-
+Olvass_el.txt
+227
+2010
+1
+6
+0
+0
+
+-
+vegleges.pdf
+19300888
+2011
+1
+15
+0
+0
+
+d
+DHI
+-1
+2011
+11
+10
+0
+0
+
+d
+English
+-1
+1994
+8
+2
+11
+48
+
+d
+Floodrisk
+-1
+2011
+6
+24
+0
+0
+
+d
+HC_MIR_FD
+-1
+1994
+3
+10
+14
+53
+
+d
+HCWP614-11
+-1
+1994
+10
+8
+15
+59
+
+d
+Mike
+-1
+1994
+3
+26
+15
+10
+
+d
+NVP anyagok
+-1
+2010
+5
+17
+0
+0
+
+d
+Oktatas
+-1
+2010
+9
+15
+0
+0
+
+d
+processing_modflow
+-1
+1994
+10
+9
+12
+47
+
+d
+Prospektushoz
+-1
+2010
+3
+24
+0
+0
+
+d
+sewcad
+-1
+2011
+9
+5
+0
+0
+
+d
+szakmernok
+-1
+1994
+5
+9
+8
+50
+
+d
+tomi
+-1
+1994
+8
+3
+18
+53
+
+d
+Virtualis-GEP
+-1
+1994
+9
+20
+21
+10
+
+d
+Vizrajzi evkonyvek
+-1
+1994
+9
+26
+12
+31
+
+d
+VKKI-Tanulmanyok
+-1
+2011
+7
+9
+0
+0
diff --git a/net/ftp/ftp_directory_listing_parser_ls.cc b/net/ftp/ftp_directory_listing_parser_ls.cc
index ab0f487..1257d5a 100644
--- a/net/ftp/ftp_directory_listing_parser_ls.cc
+++ b/net/ftp/ftp_directory_listing_parser_ls.cc
@@ -24,12 +24,13 @@ bool LooksLikeUnixPermission(const string16& text) {
// r - file is readable
// w - file is writable
// x - file is executable
- // s or S - setuid/setgid bit set
+ // s, S or l - setuid/setgid bit set
// t or T - "sticky" bit set
return ((text[0] == 'r' || text[0] == '-') &&
(text[1] == 'w' || text[1] == '-') &&
- (text[2] == 'x' || text[2] == 's' || text[2] == 'S' ||
- text[2] == 't' || text[2] == 'T' || text[2] == '-'));
+ (text[2] == 'x' || text[2] == '-' ||
+ text[2] == 's' || text[2] == 'S' || text[2] == 'l' ||
+ text[2] == 't' || text[2] == 'T'));
}
bool LooksLikeUnixPermissionsListing(const string16& text) {
@@ -180,8 +181,8 @@ bool ParseFtpDirectoryListingLs(
if (columns.size() == 2 && !received_total_line) {
received_total_line = true;
- int total_number;
- if (!base::StringToInt(columns[1], &total_number))
+ int64 total_number;
+ if (!base::StringToInt64(columns[1], &total_number))
return false;
if (total_number < 0)
return false;
diff --git a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc
index 9da23cf..456fb6e 100644
--- a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc
+++ b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc
@@ -124,6 +124,18 @@ TEST_F(FtpDirectoryListingParserLsTest, Good) {
{ "-rwxrwxrwx 2 root root 4096 2012-02-07 00:31 notas_servico",
FtpDirectoryListingEntry::FILE, "notas_servico", 4096,
2012, 2, 7, 0, 31 },
+
+ // Weird permission bits.
+ { "drwx--l--- 2 0 10 512 Dec 22 1994 swetzel",
+ FtpDirectoryListingEntry::DIRECTORY, "swetzel", -1,
+ 1994, 12, 22, 0, 0 },
+
+ // Garbage in date (but still parseable).
+ { "lrw-rw-rw- 1 user group 542 "
+ "/t11/member/incomingFeb 8 2007 "
+ "Shortcut to incoming.lnk -> /t11/member/incoming",
+ FtpDirectoryListingEntry::SYMLINK, "Shortcut to incoming.lnk", -1,
+ 2007, 2, 8, 0, 0 },
};
for (size_t i = 0; i < arraysize(good_cases); i++) {
SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
diff --git a/net/ftp/ftp_directory_listing_parser_netware.cc b/net/ftp/ftp_directory_listing_parser_netware.cc
index 1e8c80e..5a9fcfc 100644
--- a/net/ftp/ftp_directory_listing_parser_netware.cc
+++ b/net/ftp/ftp_directory_listing_parser_netware.cc
@@ -49,7 +49,7 @@ bool ParseFtpDirectoryListingNetware(
std::vector<string16> columns;
base::SplitString(CollapseWhitespace(lines[i], false), ' ', &columns);
- if (columns.size() != 8)
+ if (columns.size() < 8)
return false;
FtpDirectoryListingEntry entry;
@@ -83,7 +83,7 @@ bool ParseFtpDirectoryListingNetware(
return false;
}
- entry.name = columns[7];
+ entry.name = FtpUtil::GetStringPartAfterColumns(lines[i], 7);
entries->push_back(entry);
}
diff --git a/net/ftp/ftp_directory_listing_parser_netware_unittest.cc b/net/ftp/ftp_directory_listing_parser_netware_unittest.cc
index 5f373ac..f6715ff 100644
--- a/net/ftp/ftp_directory_listing_parser_netware_unittest.cc
+++ b/net/ftp/ftp_directory_listing_parser_netware_unittest.cc
@@ -24,6 +24,9 @@ TEST_F(FtpDirectoryListingParserNetwareTest, Good) {
{ "- [RW------] ftpadmin 123 Nov 11 18:25 afile",
FtpDirectoryListingEntry::FILE, "afile", 123,
1994, 11, 11, 18, 25 },
+ { "d [RWCEAFMS] daniel 512 May 17 2010 NVP anyagok",
+ FtpDirectoryListingEntry::DIRECTORY, "NVP anyagok", -1,
+ 2010, 5, 17, 0, 0 },
};
for (size_t i = 0; i < arraysize(good_cases); i++) {
SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
diff --git a/net/ftp/ftp_directory_listing_parser_unittest.cc b/net/ftp/ftp_directory_listing_parser_unittest.cc
index cd0ac85..02f1392 100644
--- a/net/ftp/ftp_directory_listing_parser_unittest.cc
+++ b/net/ftp/ftp_directory_listing_parser_unittest.cc
@@ -137,9 +137,11 @@ const char* kTestFiles[] = {
"dir-listing-ls-28", // Hylafax FTP server
"dir-listing-ls-29",
+ "dir-listing-ls-30",
"dir-listing-netware-1",
"dir-listing-netware-2",
+ "dir-listing-netware-3", // Spaces in file names.
"dir-listing-os2-1",
"dir-listing-vms-1",
"dir-listing-vms-2",
diff --git a/net/ftp/ftp_directory_listing_parser_vms.cc b/net/ftp/ftp_directory_listing_parser_vms.cc
index 923f25e..ce940c9 100644
--- a/net/ftp/ftp_directory_listing_parser_vms.cc
+++ b/net/ftp/ftp_directory_listing_parser_vms.cc
@@ -124,6 +124,7 @@ bool LooksLikeVmsUserIdentificationCode(const string16& input) {
bool LooksLikePermissionDeniedError(const string16& text) {
static const char* kPermissionDeniedMessages[] = {
"%RMS-E-PRV",
+ "%SYSTEM-F-NOPRIV",
"privilege",
};
diff --git a/net/ftp/ftp_util.cc b/net/ftp/ftp_util.cc
index f6bdf2f..febb350 100644
--- a/net/ftp/ftp_util.cc
+++ b/net/ftp/ftp_util.cc
@@ -203,8 +203,15 @@ bool FtpUtil::LsDateListingToTime(const string16& month, const string16& day,
base::Time* result) {
base::Time::Exploded time_exploded = { 0 };
- if (!AbbreviatedMonthToNumber(month, &time_exploded.month))
- return false;
+ if (!AbbreviatedMonthToNumber(month, &time_exploded.month)) {
+ // Work around garbage sent by some servers in the same column
+ // as the month. Take just last 3 characters of the string.
+ if (month.length() < 3 ||
+ !AbbreviatedMonthToNumber(month.substr(month.length() - 3),
+ &time_exploded.month)) {
+ return false;
+ }
+ }
if (!base::StringToInt(day, &time_exploded.day_of_month))
return false;