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

Unified Diff: net/ftp/ftp_directory_listing_buffer.cc

Issue 421006: Fix recognizing FTP listings consisting of only one line. (Closed)
Patch Set: Created 11 years, 1 month 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 | « net/ftp/ftp_directory_listing_buffer.h ('k') | net/ftp/ftp_directory_listing_buffer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_directory_listing_buffer.cc
diff --git a/net/ftp/ftp_directory_listing_buffer.cc b/net/ftp/ftp_directory_listing_buffer.cc
index e41cb9ecb6d5dbe352f7f3d0d3abbecfff37d172..19483d02341295b92a00a8da1ef84efb2d01a475 100644
--- a/net/ftp/ftp_directory_listing_buffer.cc
+++ b/net/ftp/ftp_directory_listing_buffer.cc
@@ -70,7 +70,16 @@ int FtpDirectoryListingBuffer::ProcessRemainingData() {
if (!buffer_.empty())
return ERR_INVALID_RESPONSE;
- return ParseLines();
+ rv = ParseLines();
+ if (rv != OK)
+ return rv;
+
+ rv = OnEndOfInput();
+ if (rv != OK)
+ return rv;
+
+ DCHECK(current_parser_);
+ return OK;
}
bool FtpDirectoryListingBuffer::EntryAvailable() const {
@@ -146,4 +155,24 @@ int FtpDirectoryListingBuffer::ParseLines() {
return OK;
}
+int FtpDirectoryListingBuffer::OnEndOfInput() {
+ ParserSet::iterator i = parsers_.begin();
+ while (i != parsers_.end()) {
+ if ((*i)->OnEndOfInput()) {
+ i++;
+ } else {
+ delete *i;
+ parsers_.erase(i++);
+ }
+ }
+
+ if (parsers_.size() != 1) {
+ current_parser_ = NULL;
+ return ERR_UNRECOGNIZED_FTP_DIRECTORY_LISTING_FORMAT;
+ }
+
+ current_parser_ = *parsers_.begin();
+ return OK;
+}
+
} // namespace net
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer.h ('k') | net/ftp/ftp_directory_listing_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698