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

Side by Side Diff: net/url_request/url_request_new_ftp_job.cc

Issue 159663: Fix a hang if directory listing size is > 8K, for example,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Upload before checkin Created 11 years, 4 months 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/ftp/ftp_network_transaction.cc ('k') | no next file » | 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) 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/url_request/url_request_new_ftp_job.h" 5 #include "net/url_request/url_request_new_ftp_job.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/file_version_info.h" 8 #include "base/file_version_info.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); 173 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
174 } 174 }
175 return false; 175 return false;
176 } 176 }
177 177
178 int URLRequestNewFtpJob::ProcessFtpDir(net::IOBuffer *buf, 178 int URLRequestNewFtpJob::ProcessFtpDir(net::IOBuffer *buf,
179 int buf_size, 179 int buf_size,
180 int bytes_read) { 180 int bytes_read) {
181 std::string file_entry; 181 std::string file_entry;
182 std::string line; 182 std::string line;
183 buf->data()[bytes_read] = 0;
184 183
185 // If all we've seen so far is ASCII, encoding_ is empty. Try to detect the 184 // If all we've seen so far is ASCII, encoding_ is empty. Try to detect the
186 // encoding. We don't do the separate UTF-8 check here because the encoding 185 // encoding. We don't do the separate UTF-8 check here because the encoding
187 // detection with a longer chunk (as opposed to the relatively short path 186 // detection with a longer chunk (as opposed to the relatively short path
188 // component of the url) is unlikely to mistake UTF-8 for a legacy encoding. 187 // component of the url) is unlikely to mistake UTF-8 for a legacy encoding.
189 // If it turns out to be wrong, a separate UTF-8 check has to be added. 188 // If it turns out to be wrong, a separate UTF-8 check has to be added.
190 // 189 //
191 // TODO(jungshik): UTF-8 has to be 'enforced' without any heuristics when 190 // TODO(jungshik): UTF-8 has to be 'enforced' without any heuristics when
192 // we're talking to an FTP server compliant to RFC 2640 (that is, its response 191 // we're talking to an FTP server compliant to RFC 2640 (that is, its response
193 // to FEAT command includes 'UTF8'). 192 // to FEAT command includes 'UTF8').
194 // See http://wiki.filezilla-project.org/Character_Set 193 // See http://wiki.filezilla-project.org/Character_Set
195 if (encoding_.empty()) 194 if (encoding_.empty())
196 encoding_ = DetectEncoding(buf->data(), bytes_read); 195 encoding_ = DetectEncoding(buf->data(), bytes_read);
197 196
198 int64 file_size; 197 int64 file_size;
199 std::istringstream iss(buf->data()); 198 std::istringstream iss(std::string(buf->data(), bytes_read));
200 while (getline(iss, line)) { 199 while (getline(iss, line)) {
201 struct net::ListState state; 200 struct net::ListState state;
202 struct net::ListResult result; 201 struct net::ListResult result;
203 std::replace(line.begin(), line.end(), '\r', '\0'); 202 std::replace(line.begin(), line.end(), '\r', '\0');
204 net::LineType line_type = ParseFTPLine(line.c_str(), &state, &result); 203 net::LineType line_type = ParseFTPLine(line.c_str(), &state, &result);
205 switch (line_type) { 204 switch (line_type) {
206 case net::FTP_TYPE_DIRECTORY: 205 case net::FTP_TYPE_DIRECTORY:
207 file_entry.append(net::GetDirectoryListingEntry( 206 file_entry.append(net::GetDirectoryListingEntry(
208 RawByteSequenceToFilename(result.fe_fname, encoding_), 207 RawByteSequenceToFilename(result.fe_fname, encoding_),
209 result.fe_fname, true, 0, 208 result.fe_fname, true, 0,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 293 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
295 this, &URLRequestNewFtpJob::OnStartCompleted, rv)); 294 this, &URLRequestNewFtpJob::OnStartCompleted, rv));
296 } 295 }
297 296
298 void URLRequestNewFtpJob::DestroyTransaction() { 297 void URLRequestNewFtpJob::DestroyTransaction() {
299 DCHECK(transaction_.get()); 298 DCHECK(transaction_.get());
300 299
301 transaction_.reset(); 300 transaction_.reset();
302 response_info_ = NULL; 301 response_info_ = NULL;
303 } 302 }
OLDNEW
« no previous file with comments | « net/ftp/ftp_network_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698