OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 columns[4 + column_offset], | 151 columns[4 + column_offset], |
152 columns[5 + column_offset], | 152 columns[5 + column_offset], |
153 current_time_, | 153 current_time_, |
154 &entry.last_modified)) { | 154 &entry.last_modified)) { |
155 return false; | 155 return false; |
156 } | 156 } |
157 | 157 |
158 entry.name = FtpUtil::GetStringPartAfterColumns(line, 6 + column_offset); | 158 entry.name = FtpUtil::GetStringPartAfterColumns(line, 6 + column_offset); |
159 if (entry.type == FtpDirectoryListingEntry::SYMLINK) { | 159 if (entry.type == FtpDirectoryListingEntry::SYMLINK) { |
160 string16::size_type pos = entry.name.rfind(ASCIIToUTF16(" -> ")); | 160 string16::size_type pos = entry.name.rfind(ASCIIToUTF16(" -> ")); |
161 if (pos == string16::npos) | 161 |
162 return false; | 162 // We don't require the " -> " to be present. Some FTP servers don't send |
163 entry.name = entry.name.substr(0, pos); | 163 // the symlink target, possibly for security reasons. |
| 164 if (pos != string16::npos) |
| 165 entry.name = entry.name.substr(0, pos); |
164 } | 166 } |
165 | 167 |
166 entries_.push(entry); | 168 entries_.push(entry); |
167 return true; | 169 return true; |
168 } | 170 } |
169 | 171 |
170 bool FtpDirectoryListingParserLs::OnEndOfInput() { | 172 bool FtpDirectoryListingParserLs::OnEndOfInput() { |
171 return true; | 173 return true; |
172 } | 174 } |
173 | 175 |
174 bool FtpDirectoryListingParserLs::EntryAvailable() const { | 176 bool FtpDirectoryListingParserLs::EntryAvailable() const { |
175 return !entries_.empty(); | 177 return !entries_.empty(); |
176 } | 178 } |
177 | 179 |
178 FtpDirectoryListingEntry FtpDirectoryListingParserLs::PopEntry() { | 180 FtpDirectoryListingEntry FtpDirectoryListingParserLs::PopEntry() { |
179 FtpDirectoryListingEntry entry = entries_.front(); | 181 FtpDirectoryListingEntry entry = entries_.front(); |
180 entries_.pop(); | 182 entries_.pop(); |
181 return entry; | 183 return entry; |
182 } | 184 } |
183 | 185 |
184 } // namespace net | 186 } // namespace net |
OLD | NEW |