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

Side by Side Diff: trunk/src/net/http/http_content_disposition.cc

Issue 198163004: Revert 257524 "Move IsStringASCII/UTF8 to base namespace." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/net/ftp/ftp_network_transaction.cc ('k') | trunk/src/net/proxy/proxy_resolver_v8.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/http/http_content_disposition.h" 5 #include "net/http/http_content_disposition.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/i18n/icu_string_conversions.h" 8 #include "base/i18n/icu_string_conversions.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_tokenizer.h" 10 #include "base/strings/string_tokenizer.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 bool DecodeWord(const std::string& encoded_word, 96 bool DecodeWord(const std::string& encoded_word,
97 const std::string& referrer_charset, 97 const std::string& referrer_charset,
98 bool* is_rfc2047, 98 bool* is_rfc2047,
99 std::string* output, 99 std::string* output,
100 int* parse_result_flags) { 100 int* parse_result_flags) {
101 *is_rfc2047 = false; 101 *is_rfc2047 = false;
102 output->clear(); 102 output->clear();
103 if (encoded_word.empty()) 103 if (encoded_word.empty())
104 return true; 104 return true;
105 105
106 if (!base::IsStringASCII(encoded_word)) { 106 if (!IsStringASCII(encoded_word)) {
107 // Try UTF-8, referrer_charset and the native OS default charset in turn. 107 // Try UTF-8, referrer_charset and the native OS default charset in turn.
108 if (base::IsStringUTF8(encoded_word)) { 108 if (IsStringUTF8(encoded_word)) {
109 *output = encoded_word; 109 *output = encoded_word;
110 } else { 110 } else {
111 base::string16 utf16_output; 111 base::string16 utf16_output;
112 if (!referrer_charset.empty() && 112 if (!referrer_charset.empty() &&
113 base::CodepageToUTF16(encoded_word, referrer_charset.c_str(), 113 base::CodepageToUTF16(encoded_word, referrer_charset.c_str(),
114 base::OnStringConversionError::FAIL, 114 base::OnStringConversionError::FAIL,
115 &utf16_output)) { 115 &utf16_output)) {
116 *output = base::UTF16ToUTF8(utf16_output); 116 *output = base::UTF16ToUTF8(utf16_output);
117 } else { 117 } else {
118 *output = base::WideToUTF8(base::SysNativeMBToWide(encoded_word)); 118 *output = base::WideToUTF8(base::SysNativeMBToWide(encoded_word));
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // We're not handling 'especial' characters quoted with '\', but 202 // We're not handling 'especial' characters quoted with '\', but
203 // it should be Ok because we're not an email client but a 203 // it should be Ok because we're not an email client but a
204 // web browser. 204 // web browser.
205 205
206 // What IE6/7 does: %-escaped UTF-8. 206 // What IE6/7 does: %-escaped UTF-8.
207 decoded_word = net::UnescapeURLComponent(encoded_word, 207 decoded_word = net::UnescapeURLComponent(encoded_word,
208 net::UnescapeRule::SPACES); 208 net::UnescapeRule::SPACES);
209 if (decoded_word != encoded_word) 209 if (decoded_word != encoded_word)
210 *parse_result_flags |= 210 *parse_result_flags |=
211 net::HttpContentDisposition::HAS_PERCENT_ENCODED_STRINGS; 211 net::HttpContentDisposition::HAS_PERCENT_ENCODED_STRINGS;
212 if (base::IsStringUTF8(decoded_word)) { 212 if (IsStringUTF8(decoded_word)) {
213 output->swap(decoded_word); 213 output->swap(decoded_word);
214 return true; 214 return true;
215 // We can try either the OS default charset or 'origin charset' here, 215 // We can try either the OS default charset or 'origin charset' here,
216 // As far as I can tell, IE does not support it. However, I've seen 216 // As far as I can tell, IE does not support it. However, I've seen
217 // web servers emit %-escaped string in a legacy encoding (usually 217 // web servers emit %-escaped string in a legacy encoding (usually
218 // origin charset). 218 // origin charset).
219 // TODO(jungshik) : Test IE further and consider adding a fallback here. 219 // TODO(jungshik) : Test IE further and consider adding a fallback here.
220 } 220 }
221 return false; 221 return false;
222 } 222 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 bool DecodeExtValue(const std::string& param_value, std::string* decoded) { 328 bool DecodeExtValue(const std::string& param_value, std::string* decoded) {
329 if (param_value.find('"') != std::string::npos) 329 if (param_value.find('"') != std::string::npos)
330 return false; 330 return false;
331 331
332 std::string charset; 332 std::string charset;
333 std::string value; 333 std::string value;
334 if (!ParseExtValueComponents(param_value, &charset, &value)) 334 if (!ParseExtValueComponents(param_value, &charset, &value))
335 return false; 335 return false;
336 336
337 // RFC 5987 value should be ASCII-only. 337 // RFC 5987 value should be ASCII-only.
338 if (!base::IsStringASCII(value)) { 338 if (!IsStringASCII(value)) {
339 decoded->clear(); 339 decoded->clear();
340 return true; 340 return true;
341 } 341 }
342 342
343 std::string unescaped = net::UnescapeURLComponent( 343 std::string unescaped = net::UnescapeURLComponent(
344 value, net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); 344 value, net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS);
345 345
346 return base::ConvertToUtf8AndNormalize(unescaped, charset, decoded); 346 return base::ConvertToUtf8AndNormalize(unescaped, charset, decoded);
347 } 347 }
348 348
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 447
448 if (!ext_filename.empty()) 448 if (!ext_filename.empty())
449 filename_ = ext_filename; 449 filename_ = ext_filename;
450 else if (!filename.empty()) 450 else if (!filename.empty())
451 filename_ = filename; 451 filename_ = filename;
452 else 452 else
453 filename_ = name; 453 filename_ = name;
454 } 454 }
455 455
456 } // namespace net 456 } // namespace net
OLDNEW
« no previous file with comments | « trunk/src/net/ftp/ftp_network_transaction.cc ('k') | trunk/src/net/proxy/proxy_resolver_v8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698