Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: net/ftp/ftp_directory_listing_parser_ls_unittest.cc

Issue 460139: Compatibility improvements for "ls -l" FTP LIST response format. (Closed)
Patch Set: y2038 Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_ls.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/ftp/ftp_directory_listing_parser_unittest.h" 5 #include "net/ftp/ftp_directory_listing_parser_unittest.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "net/ftp/ftp_directory_listing_parser_ls.h" 8 #include "net/ftp/ftp_directory_listing_parser_ls.h"
9 9
10 namespace { 10 namespace {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 2009, 3, 27, 0, 0 }, 47 2009, 3, 27, 0, 0 },
48 { "lrwxrwxrwx 0 0 26 Sep 18 2008 pub -> vol/1/.CLUSTER/var_ftp/pub", 48 { "lrwxrwxrwx 0 0 26 Sep 18 2008 pub -> vol/1/.CLUSTER/var_ftp/pub",
49 net::FtpDirectoryListingEntry::SYMLINK, "pub", -1, 49 net::FtpDirectoryListingEntry::SYMLINK, "pub", -1,
50 2008, 9, 18, 0, 0 }, 50 2008, 9, 18, 0, 0 },
51 { "drwxr-xr-x (?) (?) 4096 Apr 8 2007 jigdo", 51 { "drwxr-xr-x (?) (?) 4096 Apr 8 2007 jigdo",
52 net::FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1, 52 net::FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1,
53 2007, 4, 8, 0, 0 }, 53 2007, 4, 8, 0, 0 },
54 { "-rw-r--r-- 2 3 3447432 May 18 2009 Foo - Manual.pdf", 54 { "-rw-r--r-- 2 3 3447432 May 18 2009 Foo - Manual.pdf",
55 net::FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432, 55 net::FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432,
56 2009, 5, 18, 0, 0 }, 56 2009, 5, 18, 0, 0 },
57
58 // Tests for "ls -l" style listings sent by an OS/2 server (FtpServer):
59 { "-r--r--r-- 1 ftp -A--- 13274 Mar 1 2006 UpTime.exe",
60 net::FtpDirectoryListingEntry::FILE, "UpTime.exe", 13274,
61 2006, 3, 1, 0, 0 },
62 { "dr--r--r-- 1 ftp ----- 0 Nov 17 17:08 kernels",
63 net::FtpDirectoryListingEntry::DIRECTORY, "kernels", -1,
64 now_exploded.year, 11, 17, 17, 8 },
65
66 // Tests for "ls -l" style listing sent by Xplain FTP Server.
67 { "drwxr-xr-x folder 0 Jul 17 2006 online",
68 net::FtpDirectoryListingEntry::DIRECTORY, "online", -1,
69 2006, 7, 17, 0, 0 },
57 }; 70 };
58 for (size_t i = 0; i < arraysize(good_cases); i++) { 71 for (size_t i = 0; i < arraysize(good_cases); i++) {
59 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); 72 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input));
60 73
61 net::FtpDirectoryListingParserLs parser; 74 net::FtpDirectoryListingParserLs parser;
62 RunSingleLineTestCase(&parser, good_cases[i]); 75 RunSingleLineTestCase(&parser, good_cases[i]);
63 } 76 }
64 } 77 }
65 78
66 TEST_F(FtpDirectoryListingParserLsTest, Bad) { 79 TEST_F(FtpDirectoryListingParserLsTest, Bad) {
67 const char* bad_cases[] = { 80 const char* bad_cases[] = {
68 "garbage", 81 "garbage",
69 "-rw-r--r-- ftp ftp", 82 "-rw-r--r-- ftp ftp",
70 "-rw-r--rgb ftp ftp 528 Nov 01 2007 README", 83 "-rw-r--rgb ftp ftp 528 Nov 01 2007 README",
71 "-rw-rgbr-- ftp ftp 528 Nov 01 2007 README", 84 "-rw-rgbr-- ftp ftp 528 Nov 01 2007 README",
72 "qrwwr--r-- ftp ftp 528 Nov 01 2007 README", 85 "qrwwr--r-- ftp ftp 528 Nov 01 2007 README",
73 "-rw-r--r-- ftp ftp -528 Nov 01 2007 README", 86 "-rw-r--r-- ftp ftp -528 Nov 01 2007 README",
74 "-rw-r--r-- ftp ftp 528 Foo 01 2007 README", 87 "-rw-r--r-- ftp ftp 528 Foo 01 2007 README",
75 "-rw-r--r-- 1 ftp ftp", 88 "-rw-r--r-- 1 ftp ftp",
76 "-rw-r--rgb 1 ftp ftp 528 Nov 01 2007 README", 89 "-rw-r--rgb 1 ftp ftp 528 Nov 01 2007 README",
77 "-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README", 90 "-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README",
78 "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README", 91 "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README",
79 "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README", 92 "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README",
80 "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README", 93 "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README",
94
95 // Tests important for security: verify that after we detect the column
96 // offset we don't try to access invalid memory on malformed input.
97 "drwxr-xr-x 3 ftp ftp 4096 May 15 18:11",
98 "drwxr-xr-x 3 ftp 4096 May 15 18:11",
99 "drwxr-xr-x folder 0 May 15 18:11",
81 }; 100 };
82 for (size_t i = 0; i < arraysize(bad_cases); i++) { 101 for (size_t i = 0; i < arraysize(bad_cases); i++) {
83 net::FtpDirectoryListingParserLs parser; 102 net::FtpDirectoryListingParserLs parser;
84 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; 103 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i];
85 } 104 }
86 } 105 }
87 106
88 } // namespace 107 } // namespace
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_ls.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698