| OLD | NEW |
| 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 22 matching lines...) Expand all Loading... |
| 33 2007, 2, 20, 0, 0 }, | 33 2007, 2, 20, 0, 0 }, |
| 34 { "drwxr-xr-x 4 (?) (?) 4096 Apr 8 2007 jigdo", | 34 { "drwxr-xr-x 4 (?) (?) 4096 Apr 8 2007 jigdo", |
| 35 net::FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1, | 35 net::FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1, |
| 36 2007, 4, 8, 0, 0 }, | 36 2007, 4, 8, 0, 0 }, |
| 37 { "drwx-wx-wt 2 root wheel 512 Jul 1 02:15 incoming", | 37 { "drwx-wx-wt 2 root wheel 512 Jul 1 02:15 incoming", |
| 38 net::FtpDirectoryListingEntry::DIRECTORY, "incoming", -1, | 38 net::FtpDirectoryListingEntry::DIRECTORY, "incoming", -1, |
| 39 now_exploded.year, 7, 1, 2, 15 }, | 39 now_exploded.year, 7, 1, 2, 15 }, |
| 40 { "-rw-r--r-- 1 2 3 3447432 May 18 2009 Foo - Manual.pdf", | 40 { "-rw-r--r-- 1 2 3 3447432 May 18 2009 Foo - Manual.pdf", |
| 41 net::FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432, | 41 net::FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432, |
| 42 2009, 5, 18, 0, 0 }, | 42 2009, 5, 18, 0, 0 }, |
| 43 { "d-wx-wx-wt+ 4 ftp 989 512 Dec 8 15:54 incoming", |
| 44 net::FtpDirectoryListingEntry::DIRECTORY, "incoming", -1, |
| 45 now_exploded.year, 12, 8, 15, 54 }, |
| 43 | 46 |
| 44 // Tests for the wu-ftpd variant: | 47 // Tests for the wu-ftpd variant: |
| 45 { "drwxr-xr-x 2 sys 512 Mar 27 2009 pub", | 48 { "drwxr-xr-x 2 sys 512 Mar 27 2009 pub", |
| 46 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, | 49 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, |
| 47 2009, 3, 27, 0, 0 }, | 50 2009, 3, 27, 0, 0 }, |
| 48 { "lrwxrwxrwx 0 0 26 Sep 18 2008 pub -> vol/1/.CLUSTER/var_ftp/pub", | 51 { "lrwxrwxrwx 0 0 26 Sep 18 2008 pub -> vol/1/.CLUSTER/var_ftp/pub", |
| 49 net::FtpDirectoryListingEntry::SYMLINK, "pub", -1, | 52 net::FtpDirectoryListingEntry::SYMLINK, "pub", -1, |
| 50 2008, 9, 18, 0, 0 }, | 53 2008, 9, 18, 0, 0 }, |
| 51 { "drwxr-xr-x (?) (?) 4096 Apr 8 2007 jigdo", | 54 { "drwxr-xr-x (?) (?) 4096 Apr 8 2007 jigdo", |
| 52 net::FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1, | 55 net::FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 "qrwwr--r-- ftp ftp 528 Nov 01 2007 README", | 88 "qrwwr--r-- ftp ftp 528 Nov 01 2007 README", |
| 86 "-rw-r--r-- ftp ftp -528 Nov 01 2007 README", | 89 "-rw-r--r-- ftp ftp -528 Nov 01 2007 README", |
| 87 "-rw-r--r-- ftp ftp 528 Foo 01 2007 README", | 90 "-rw-r--r-- ftp ftp 528 Foo 01 2007 README", |
| 88 "-rw-r--r-- 1 ftp ftp", | 91 "-rw-r--r-- 1 ftp ftp", |
| 89 "-rw-r--rgb 1 ftp ftp 528 Nov 01 2007 README", | 92 "-rw-r--rgb 1 ftp ftp 528 Nov 01 2007 README", |
| 90 "-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README", | 93 "-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README", |
| 91 "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README", | 94 "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README", |
| 92 "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README", | 95 "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README", |
| 93 "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README", | 96 "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README", |
| 94 | 97 |
| 98 "d-wx-wx-wt++ 4 ftp 989 512 Dec 8 15:54 incoming", |
| 99 "d-wx-wx-wt$ 4 ftp 989 512 Dec 8 15:54 incoming", |
| 100 "-qqqqqqqqq+ 2 sys 512 Mar 27 2009 pub", |
| 101 |
| 95 // Tests important for security: verify that after we detect the column | 102 // Tests important for security: verify that after we detect the column |
| 96 // offset we don't try to access invalid memory on malformed input. | 103 // offset we don't try to access invalid memory on malformed input. |
| 97 "drwxr-xr-x 3 ftp ftp 4096 May 15 18:11", | 104 "drwxr-xr-x 3 ftp ftp 4096 May 15 18:11", |
| 98 "drwxr-xr-x 3 ftp 4096 May 15 18:11", | 105 "drwxr-xr-x 3 ftp 4096 May 15 18:11", |
| 99 "drwxr-xr-x folder 0 May 15 18:11", | 106 "drwxr-xr-x folder 0 May 15 18:11", |
| 100 }; | 107 }; |
| 101 for (size_t i = 0; i < arraysize(bad_cases); i++) { | 108 for (size_t i = 0; i < arraysize(bad_cases); i++) { |
| 102 net::FtpDirectoryListingParserLs parser; | 109 net::FtpDirectoryListingParserLs parser; |
| 103 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; | 110 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; |
| 104 } | 111 } |
| 105 } | 112 } |
| 106 | 113 |
| 107 } // namespace | 114 } // namespace |
| OLD | NEW |