diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 21:46:25 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 21:46:25 +0000 |
commit | 63cdfb96a08d384963ee792c4a6687009b0dc10b (patch) | |
tree | e8280d14c578937bd75380e22aeeacba1c4de79f | |
parent | 4d5bfc090b95c6f1f87200f27989c4f1fdb4fd5e (diff) | |
download | chromium_src-63cdfb96a08d384963ee792c4a6687009b0dc10b.zip chromium_src-63cdfb96a08d384963ee792c4a6687009b0dc10b.tar.gz chromium_src-63cdfb96a08d384963ee792c4a6687009b0dc10b.tar.bz2 |
Fix FTP directory listings for servers which use \n as the line break.
The previous version of the code assumed that \r\n (CRLF) will always be used.
The FTP spec is extremely imprecise about the LISTing format.
TEST=See bug.
BUG=22879
Review URL: http://codereview.chromium.org/238001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27128 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/glue/ftp_directory_listing_response_delegate.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/webkit/glue/ftp_directory_listing_response_delegate.cc b/webkit/glue/ftp_directory_listing_response_delegate.cc index a0ee89d..c11fdbd 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); } |