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

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

Issue 472003: Compatibility updates for "ls -l" style FTP LIST response parser: (Closed)
Patch Set: fix a bug 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "net/ftp/ftp_directory_listing_parser_ls.h" 5 #include "net/ftp/ftp_directory_listing_parser_ls.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/ftp/ftp_util.h" 10 #include "net/ftp/ftp_util.h"
(...skipping 10 matching lines...) Expand all
21 // x - file is executable 21 // x - file is executable
22 // s or S - setuid/setgid bit set 22 // s or S - setuid/setgid bit set
23 // t or T - "sticky" bit set 23 // t or T - "sticky" bit set
24 return ((text[0] == 'r' || text[0] == '-') && 24 return ((text[0] == 'r' || text[0] == '-') &&
25 (text[1] == 'w' || text[1] == '-') && 25 (text[1] == 'w' || text[1] == '-') &&
26 (text[2] == 'x' || text[2] == 's' || text[2] == 'S' || 26 (text[2] == 'x' || text[2] == 's' || text[2] == 'S' ||
27 text[2] == 't' || text[2] == 'T' || text[2] == '-')); 27 text[2] == 't' || text[2] == 'T' || text[2] == '-'));
28 } 28 }
29 29
30 bool LooksLikeUnixPermissionsListing(const string16& text) { 30 bool LooksLikeUnixPermissionsListing(const string16& text) {
31 if (text.length() != 10) 31 if (text.length() < 10)
32 return false; 32 return false;
33 33
34 if (text[0] != 'b' && text[0] != 'c' && text[0] != 'd' && 34 if (text[0] != 'b' && text[0] != 'c' && text[0] != 'd' &&
35 text[0] != 'l' && text[0] != 'p' && text[0] != 's' && 35 text[0] != 'l' && text[0] != 'p' && text[0] != 's' &&
36 text[0] != '-') 36 text[0] != '-')
37 return false; 37 return false;
38 38
39 return (LooksLikeUnixPermission(text.substr(1, 3)) && 39 return (LooksLikeUnixPermission(text.substr(1, 3)) &&
40 LooksLikeUnixPermission(text.substr(4, 3)) && 40 LooksLikeUnixPermission(text.substr(4, 3)) &&
41 LooksLikeUnixPermission(text.substr(7, 3))); 41 LooksLikeUnixPermission(text.substr(7, 3)) &&
42 (text.substr(10).empty() || text.substr(10) == ASCIIToUTF16("+")));
42 } 43 }
43 44
44 string16 GetStringPartAfterColumns(const string16& text, int columns) { 45 string16 GetStringPartAfterColumns(const string16& text, int columns) {
45 DCHECK_LE(1, columns); 46 DCHECK_LE(1, columns);
46 int columns_so_far = 0; 47 int columns_so_far = 0;
47 size_t last = 0; 48 size_t last = 0;
48 for (size_t i = 1; i < text.length(); ++i) { 49 for (size_t i = 1; i < text.length(); ++i) {
49 if (!isspace(text[i - 1]) && isspace(text[i])) { 50 if (!isspace(text[i - 1]) && isspace(text[i])) {
50 last = i; 51 last = i;
51 if (++columns_so_far == columns) 52 if (++columns_so_far == columns)
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 return !entries_.empty(); 184 return !entries_.empty();
184 } 185 }
185 186
186 FtpDirectoryListingEntry FtpDirectoryListingParserLs::PopEntry() { 187 FtpDirectoryListingEntry FtpDirectoryListingParserLs::PopEntry() {
187 FtpDirectoryListingEntry entry = entries_.front(); 188 FtpDirectoryListingEntry entry = entries_.front();
188 entries_.pop(); 189 entries_.pop();
189 return entry; 190 return entry;
190 } 191 }
191 192
192 } // namespace net 193 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer_unittest.cc ('k') | net/ftp/ftp_directory_listing_parser_ls_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698