Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ftp/ftp_directory_listing_parser.h" | 5 #include "net/ftp/ftp_directory_listing_parser.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/i18n/encoding_detection.h" | 9 #include "base/i18n/encoding_detection.h" |
| 10 #include "base/i18n/icu_string_conversions.h" | 10 #include "base/i18n/icu_string_conversions.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 const base::Time& current_time, | 84 const base::Time& current_time, |
| 85 std::vector<FtpDirectoryListingEntry>* entries, | 85 std::vector<FtpDirectoryListingEntry>* entries, |
| 86 FtpServerType* server_type) { | 86 FtpServerType* server_type) { |
| 87 std::string encoding; | 87 std::string encoding; |
| 88 if (!base::DetectEncoding(text, &encoding)) | 88 if (!base::DetectEncoding(text, &encoding)) |
| 89 return ERR_ENCODING_DETECTION_FAILED; | 89 return ERR_ENCODING_DETECTION_FAILED; |
| 90 const char* encoding_name = encoding.c_str(); | 90 const char* encoding_name = encoding.c_str(); |
| 91 | 91 |
| 92 base::string16 converted_text; | 92 base::string16 converted_text; |
| 93 if (base::CodepageToUTF16(text, encoding_name, | 93 if (base::CodepageToUTF16(text, encoding_name, |
| 94 base::OnStringConversionError::FAIL, | 94 base::OnStringConversionError::SKIP, |
|
mmenke
2017/01/05 00:20:53
Would SUBSTITUTE be better, so we display a charac
Jinsuk Kim
2017/01/05 00:25:39
Tried this but then the processing in |ParseListin
Jinsuk Kim
2017/01/05 00:45:28
Your feedback got me to look into it further... SU
| |
| 95 &converted_text)) { | 95 &converted_text)) { |
| 96 const char* const kNewlineSeparators[] = {"\n", "\r\n"}; | 96 const char* const kNewlineSeparators[] = {"\n", "\r\n"}; |
| 97 | 97 |
| 98 for (size_t j = 0; j < arraysize(kNewlineSeparators); j++) { | 98 for (size_t j = 0; j < arraysize(kNewlineSeparators); j++) { |
| 99 int rv = ParseListing(converted_text, | 99 int rv = ParseListing(converted_text, |
| 100 base::ASCIIToUTF16(kNewlineSeparators[j]), | 100 base::ASCIIToUTF16(kNewlineSeparators[j]), |
| 101 encoding_name, current_time, entries, server_type); | 101 encoding_name, current_time, entries, server_type); |
| 102 if (rv == OK) | 102 if (rv == OK) |
| 103 return rv; | 103 return rv; |
| 104 } | 104 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 119 int ParseFtpDirectoryListing(const std::string& text, | 119 int ParseFtpDirectoryListing(const std::string& text, |
| 120 const base::Time& current_time, | 120 const base::Time& current_time, |
| 121 std::vector<FtpDirectoryListingEntry>* entries) { | 121 std::vector<FtpDirectoryListingEntry>* entries) { |
| 122 FtpServerType server_type = SERVER_UNKNOWN; | 122 FtpServerType server_type = SERVER_UNKNOWN; |
| 123 int rv = DecodeAndParse(text, current_time, entries, &server_type); | 123 int rv = DecodeAndParse(text, current_time, entries, &server_type); |
| 124 UpdateFtpServerTypeHistograms(server_type); | 124 UpdateFtpServerTypeHistograms(server_type); |
| 125 return rv; | 125 return rv; |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace net | 128 } // namespace net |
| OLD | NEW |