Index: net/ftp/ftp_directory_listing_parser.cc |
diff --git a/net/ftp/ftp_directory_listing_parser.cc b/net/ftp/ftp_directory_listing_parser.cc |
index d7c7c7d3b281cb84b6c271d926868a8588271392..3cacee07619e59d93bc0e9f286811226ac9ba30c 100644 |
--- a/net/ftp/ftp_directory_listing_parser.cc |
+++ b/net/ftp/ftp_directory_listing_parser.cc |
@@ -11,6 +11,7 @@ |
#include "base/stl_util.h" |
#include "base/string_split.h" |
#include "base/string_util.h" |
+#include "base/utf_string_conversions.h" |
#include "net/base/net_errors.h" |
#include "net/ftp/ftp_directory_listing_parser_ls.h" |
#include "net/ftp/ftp_directory_listing_parser_netware.h" |
@@ -41,12 +42,13 @@ int FillInRawName(const std::string& encoding, |
// Parses |text| as an FTP directory listing. Fills in |entries| |
// and |server_type| and returns network error code. |
int ParseListing(const string16& text, |
+ const string16& newline_separator, |
const std::string& encoding, |
const base::Time& current_time, |
std::vector<FtpDirectoryListingEntry>* entries, |
FtpServerType* server_type) { |
std::vector<string16> lines; |
- base::SplitString(text, '\n', &lines); |
+ base::SplitStringUsingSubstr(text, newline_separator, &lines); |
struct { |
base::Callback<bool(void)> callback; |
@@ -93,6 +95,8 @@ int DecodeAndParse(const std::string& text, |
const base::Time& current_time, |
std::vector<FtpDirectoryListingEntry>* entries, |
FtpServerType* server_type) { |
+ const char* kNewlineSeparators[] = { "\n", "\r\n" }; |
+ |
std::vector<std::string> encodings; |
if (!base::DetectAllEncodings(text, &encodings)) |
return ERR_ENCODING_DETECTION_FAILED; |
@@ -104,13 +108,16 @@ int DecodeAndParse(const std::string& text, |
encodings[i].c_str(), |
base::OnStringConversionError::FAIL, |
&converted_text)) { |
- int rv = ParseListing(converted_text, |
- encodings[i], |
- current_time, |
- entries, |
- server_type); |
- if (rv == OK) |
- return rv; |
+ for (size_t j = 0; j < arraysize(kNewlineSeparators); j++) { |
+ int rv = ParseListing(converted_text, |
+ ASCIIToUTF16(kNewlineSeparators[j]), |
+ encodings[i], |
+ current_time, |
+ entries, |
+ server_type); |
+ if (rv == OK) |
+ return rv; |
+ } |
} |
} |