| Index: net/base/net_util.cc
|
| diff --git a/net/base/net_util.cc b/net/base/net_util.cc
|
| index 60f626d44cec4bbd9c223475485c35f912923523..5eb2e68f4648f417f186d56503643bba7c2eccb8 100644
|
| --- a/net/base/net_util.cc
|
| +++ b/net/base/net_util.cc
|
| @@ -272,6 +272,11 @@ bool DecodeWord(const std::string& encoded_word,
|
| const std::string& referrer_charset,
|
| bool* is_rfc2047,
|
| std::string* output) {
|
| + *is_rfc2047 = false;
|
| + output->clear();
|
| + if (encoded_word.empty())
|
| + return true;
|
| +
|
| if (!IsStringASCII(encoded_word)) {
|
| // Try UTF-8, referrer_charset and the native OS default charset in turn.
|
| if (IsStringUTF8(encoded_word)) {
|
| @@ -287,7 +292,7 @@ bool DecodeWord(const std::string& encoded_word,
|
| *output = WideToUTF8(base::SysNativeMBToWide(encoded_word));
|
| }
|
| }
|
| - *is_rfc2047 = false;
|
| +
|
| return true;
|
| }
|
|
|
| @@ -1081,7 +1086,7 @@ FilePath GetSuggestedFilename(const GURL& url,
|
| }
|
|
|
| const std::string filename_from_cd = GetFileNameFromCD(content_disposition,
|
| - referrer_charset);
|
| + referrer_charset);
|
| #if defined(OS_WIN)
|
| FilePath::StringType filename = UTF8ToWide(filename_from_cd);
|
| #elif defined(OS_POSIX)
|
| @@ -1102,10 +1107,21 @@ FilePath GetSuggestedFilename(const GURL& url,
|
| const std::string unescaped_url_filename = UnescapeURLComponent(
|
| url.ExtractFileName(),
|
| UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS);
|
| +
|
| + // The URL's path should be escaped UTF-8, but may not be.
|
| + std::string decoded_filename = unescaped_url_filename;
|
| + if (!IsStringASCII(decoded_filename)) {
|
| + bool ignore;
|
| + // TODO(jshin): this is probably not robust enough. To be sure, we
|
| + // need encoding detection.
|
| + DecodeWord(unescaped_url_filename, referrer_charset, &ignore,
|
| + &decoded_filename);
|
| + }
|
| +
|
| #if defined(OS_WIN)
|
| - filename = UTF8ToWide(unescaped_url_filename);
|
| + filename = UTF8ToWide(decoded_filename);
|
| #elif defined(OS_POSIX)
|
| - filename = unescaped_url_filename;
|
| + filename = decoded_filename;
|
| #endif
|
| }
|
| }
|
|
|