OLD | NEW |
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 if (!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 (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 = UTF16ToUTF8(utf16_output); | 116 *output = base::UTF16ToUTF8(utf16_output); |
117 } else { | 117 } else { |
118 *output = WideToUTF8(base::SysNativeMBToWide(encoded_word)); | 118 *output = base::WideToUTF8(base::SysNativeMBToWide(encoded_word)); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 *parse_result_flags |= net::HttpContentDisposition::HAS_NON_ASCII_STRINGS; | 122 *parse_result_flags |= net::HttpContentDisposition::HAS_NON_ASCII_STRINGS; |
123 return true; | 123 return true; |
124 } | 124 } |
125 | 125 |
126 // RFC 2047 : one of encoding methods supported by Firefox and relatively | 126 // RFC 2047 : one of encoding methods supported by Firefox and relatively |
127 // widely used by web servers. | 127 // widely used by web servers. |
128 // =?charset?<E>?<encoded string>?= where '<E>' is either 'B' or 'Q'. | 128 // =?charset?<E>?<encoded string>?= where '<E>' is either 'B' or 'Q'. |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |