summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-08 23:48:17 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-08 23:48:17 +0000
commit2d0c4aa7177a7996eb3bad4f0bd445b00491692f (patch)
treefbd2dbce4cd2fae2cb6408b34cb034619e514c10 /net
parent8870119a4797f34cdcb7f0c77327abaced5d30f7 (diff)
downloadchromium_src-2d0c4aa7177a7996eb3bad4f0bd445b00491692f.zip
chromium_src-2d0c4aa7177a7996eb3bad4f0bd445b00491692f.tar.gz
chromium_src-2d0c4aa7177a7996eb3bad4f0bd445b00491692f.tar.bz2
Download filename encoding fix:
Fall back on other charsets when using the URL to suggest a filename. The URL should be escaped UTF-8, but may use another encoding instead. BUG=44301 TEST=see bug. Review URL: http://codereview.chromium.org/2635006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49217 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/net_util.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index 60f626d4..490feab 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -1081,7 +1081,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 +1102,17 @@ FilePath GetSuggestedFilename(const GURL& url,
const std::string unescaped_url_filename = UnescapeURLComponent(
url.ExtractFileName(),
UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS);
+
+ // The URL should be escaped UTF-8, but may not be.
+ std::string decoded_filename;
+ bool ignore;
+ 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
}
}