FTP: fix directory listing parsing for Hylafax

BUG=90807

Review URL: http://codereview.chromium.org/7584018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96073 0039d316-1c4b-4281-b951-d872f2087c98
parent 71703c8c
drwxr-x 2 10 4096 Dec 10 14:32 pollq
drwxr-x 4 0 4096 Jul 28 01:44 etc
drwxrwx 2 10 4096 Jul 28 02:41 tmp
drwxr-x 2 10 4096 Jul 28 02:00 status
drwxr-x 2 0 4096 Jul 27 23:21 bin
d
pollq
-1
1993
12
10
14
32
d
etc
-1
1994
7
28
1
44
d
tmp
-1
1994
7
28
2
41
d
status
-1
1994
7
28
2
0
d
bin
-1
1994
7
27
23
21
......@@ -33,7 +33,7 @@ bool LooksLikeUnixPermission(const string16& text) {
}
bool LooksLikeUnixPermissionsListing(const string16& text) {
if (text.length() < 10)
if (text.length() < 7)
return false;
// Do not check the first character (entry type). There are many weird
......@@ -44,9 +44,11 @@ bool LooksLikeUnixPermissionsListing(const string16& text) {
// 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.
// In fact, we don't even expect three "rwx" triplets of permission
// listing, as some FTP servers like Hylafax only send two.
return (LooksLikeUnixPermission(text.substr(1, 3)) &&
LooksLikeUnixPermission(text.substr(4, 3)) &&
LooksLikeUnixPermission(text.substr(7, 3)));
LooksLikeUnixPermission(text.substr(4, 3)));
}
bool LooksLikePermissionDeniedError(const string16& text) {
......
......@@ -108,6 +108,11 @@ TEST_F(FtpDirectoryListingParserLsTest, Good) {
{ "ar-xr-xr-x 2 none none 512 Apr 26 17:52 plan9",
FtpDirectoryListingEntry::FILE, "plan9", 512,
1994, 4, 26, 17, 52 },
// Hylafax sends a shorter permission listing.
{ "drwxrwx 2 10 4096 Jul 28 02:41 tmp",
FtpDirectoryListingEntry::DIRECTORY, "tmp", -1,
1994, 7, 28, 2, 41 },
};
for (size_t i = 0; i < arraysize(good_cases); i++) {
SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
......@@ -153,13 +158,11 @@ TEST_F(FtpDirectoryListingParserLsTest, Bad) {
" foo",
"garbage",
"-rw-r--r-- ftp ftp",
"-rw-r--rgb ftp ftp 528 Nov 01 2007 README",
"-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-r--rgb 1 ftp ftp 528 Nov 01 2007 README",
"-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",
......
......@@ -135,6 +135,8 @@ const char* kTestFiles[] = {
"dir-listing-ls-26", // KOI8-R
"dir-listing-ls-27", // windows-1251
"dir-listing-ls-28", // Hylafax FTP server
"dir-listing-netware-1",
"dir-listing-netware-2",
"dir-listing-vms-1",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment