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

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

Issue 8970023: FTP: work around server bugs resulting in negative file size being sent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « net/base/net_util.cc ('k') | net/ftp/ftp_directory_listing_parser_ls_unittest.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 if (!base::StringToInt64(columns[column_offset - 3], &entry.size)) { 181 if (!base::StringToInt64(columns[column_offset - 3], &entry.size)) {
182 // Some FTP servers do not separate owning group name from file size, 182 // Some FTP servers do not separate owning group name from file size,
183 // like "group1234". We still want to display the file name for that 183 // like "group1234". We still want to display the file name for that
184 // entry, but can't really get the size (What if the group is named 184 // entry, but can't really get the size (What if the group is named
185 // "group1", and the size is in fact 234? We can't distinguish between 185 // "group1", and the size is in fact 234? We can't distinguish between
186 // that and "group" with size 1234). Use a dummy value for the size. 186 // that and "group" with size 1234). Use a dummy value for the size.
187 // TODO(phajdan.jr): Use a value that means "unknown" instead of 0 bytes. 187 // TODO(phajdan.jr): Use a value that means "unknown" instead of 0 bytes.
188 entry.size = 0; 188 entry.size = 0;
189 } 189 }
190 if (entry.size < 0) 190 if (entry.size < 0) {
191 return false; 191 // Some FTP servers have bugs that cause them to display the file size
192 // as negative. They're most likely big files like DVD ISO images.
193 // We still want to display them, so just say the real file size
194 // is unknown.
195 entry.size = -1;
196 }
192 if (entry.type != FtpDirectoryListingEntry::FILE) 197 if (entry.type != FtpDirectoryListingEntry::FILE)
193 entry.size = -1; 198 entry.size = -1;
194 199
195 if (column_offset == columns.size() - 1) { 200 if (column_offset == columns.size() - 1) {
196 // If the end of the date listing is the last column, there is no file 201 // If the end of the date listing is the last column, there is no file
197 // name. Some FTP servers send listing entries with empty names. 202 // name. Some FTP servers send listing entries with empty names.
198 // It's not obvious how to display such an entry, so we ignore them. 203 // It's not obvious how to display such an entry, so we ignore them.
199 // We don't want to make the parsing fail at this point though. 204 // We don't want to make the parsing fail at this point though.
200 // Other entries can still be useful. 205 // Other entries can still be useful.
201 continue; 206 continue;
(...skipping 11 matching lines...) Expand all
213 entry.name = entry.name.substr(0, pos); 218 entry.name = entry.name.substr(0, pos);
214 } 219 }
215 220
216 entries->push_back(entry); 221 entries->push_back(entry);
217 } 222 }
218 223
219 return true; 224 return true;
220 } 225 }
221 226
222 } // namespace net 227 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util.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