OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_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/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 base::string16 size; | 160 base::string16 size; |
161 if (!DetectColumnOffsetSizeAndModificationTime(columns, | 161 if (!DetectColumnOffsetSizeAndModificationTime(columns, |
162 current_time, | 162 current_time, |
163 &column_offset, | 163 &column_offset, |
164 &size, | 164 &size, |
165 &entry.last_modified)) { | 165 &entry.last_modified)) { |
166 // Some servers send a message in one of the first few lines. | 166 // Some servers send a message in one of the first few lines. |
167 // All those messages have in common is the string ".:", | 167 // All those messages have in common is the string ".:", |
168 // where "." means the current directory, and ":" separates it | 168 // where "." means the current directory, and ":" separates it |
169 // from the rest of the message, which may be empty. | 169 // from the rest of the message, which may be empty. |
170 if (lines[i].find(ASCIIToUTF16(".:")) != base::string16::npos) | 170 if (lines[i].find(base::ASCIIToUTF16(".:")) != base::string16::npos) |
171 continue; | 171 continue; |
172 | 172 |
173 return false; | 173 return false; |
174 } | 174 } |
175 | 175 |
176 // Do not check "validity" of the permission listing. It's quirky, | 176 // Do not check "validity" of the permission listing. It's quirky, |
177 // and some servers send garbage here while other parts of the line are OK. | 177 // and some servers send garbage here while other parts of the line are OK. |
178 | 178 |
179 if (!columns[0].empty() && columns[0][0] == 'l') { | 179 if (!columns[0].empty() && columns[0][0] == 'l') { |
180 entry.type = FtpDirectoryListingEntry::SYMLINK; | 180 entry.type = FtpDirectoryListingEntry::SYMLINK; |
(...skipping 28 matching lines...) Expand all Loading... |
209 // It's not obvious how to display such an entry, so we ignore them. | 209 // It's not obvious how to display such an entry, so we ignore them. |
210 // We don't want to make the parsing fail at this point though. | 210 // We don't want to make the parsing fail at this point though. |
211 // Other entries can still be useful. | 211 // Other entries can still be useful. |
212 continue; | 212 continue; |
213 } | 213 } |
214 | 214 |
215 entry.name = FtpUtil::GetStringPartAfterColumns(lines[i], | 215 entry.name = FtpUtil::GetStringPartAfterColumns(lines[i], |
216 column_offset + 1); | 216 column_offset + 1); |
217 | 217 |
218 if (entry.type == FtpDirectoryListingEntry::SYMLINK) { | 218 if (entry.type == FtpDirectoryListingEntry::SYMLINK) { |
219 base::string16::size_type pos = entry.name.rfind(ASCIIToUTF16(" -> ")); | 219 base::string16::size_type pos = |
| 220 entry.name.rfind(base::ASCIIToUTF16(" -> ")); |
220 | 221 |
221 // We don't require the " -> " to be present. Some FTP servers don't send | 222 // We don't require the " -> " to be present. Some FTP servers don't send |
222 // the symlink target, possibly for security reasons. | 223 // the symlink target, possibly for security reasons. |
223 if (pos != base::string16::npos) | 224 if (pos != base::string16::npos) |
224 entry.name = entry.name.substr(0, pos); | 225 entry.name = entry.name.substr(0, pos); |
225 } | 226 } |
226 | 227 |
227 entries->push_back(entry); | 228 entries->push_back(entry); |
228 } | 229 } |
229 | 230 |
230 return true; | 231 return true; |
231 } | 232 } |
232 | 233 |
233 } // namespace net | 234 } // namespace net |
OLD | NEW |