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

Unified Diff: webkit/glue/ftp_directory_listing_response_delegate.cc

Issue 238001: Fix FTP directory listings for servers which use \n as the line break. (Closed)
Patch Set: updated Created 11 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/ftp_directory_listing_response_delegate.cc
diff --git a/webkit/glue/ftp_directory_listing_response_delegate.cc b/webkit/glue/ftp_directory_listing_response_delegate.cc
index a0ee89dd764a5a9cbe6f489a7786719f5e17a7cc..c11fdbd8b8f6932b770f3b439566be38b63bad83 100644
--- a/webkit/glue/ftp_directory_listing_response_delegate.cc
+++ b/webkit/glue/ftp_directory_listing_response_delegate.cc
@@ -63,10 +63,13 @@ void ExtractFullLinesFromBuffer(std::string* buffer,
std::vector<std::string>* lines) {
int cut_pos = 0;
for (size_t i = 0; i < buffer->length(); i++) {
- if (i >= 1 && (*buffer)[i - 1] == '\r' && (*buffer)[i] == '\n') {
- lines->push_back(buffer->substr(cut_pos, i - cut_pos - 1));
- cut_pos = i + 1;
- }
+ if ((*buffer)[i] != '\n')
+ continue;
+ size_t line_length = i - cut_pos;
+ if (line_length > 0 && (*buffer)[i - 1] == '\r')
+ line_length--;
+ lines->push_back(buffer->substr(cut_pos, line_length));
+ cut_pos = i + 1;
}
buffer->erase(0, cut_pos);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698