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

Unified Diff: net/base/net_util.h

Issue 83002: download filename fix (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | net/base/net_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_util.h
===================================================================
--- net/base/net_util.h (revision 15065)
+++ net/base/net_util.h (working copy)
@@ -71,12 +71,20 @@
std::string GetHeaderParamValue(const std::string& field,
const std::string& param_name);
-// Return the filename extracted from Content-Disposition header. Only two
-// formats are supported: a. %-escaped UTF-8 b. RFC 2047.
+// Return the filename extracted from Content-Disposition header. The following
+// formats are tried in order listed below:
//
-// A non-ASCII param value is just returned as it is (assuming a NativeMB
-// encoding). When a param value is ASCII, but is not in one of two forms
-// supported, it is returned as it is unless it's pretty close to two supported
+// 1. RFC 2047
+// 2. Raw-8bit-characters :
+// a. UTF-8, b. referrer_charset, c. default os codepage.
+// 3. %-escaped UTF-8.
+//
+// In step 2, if referrer_charset is empty(i.e. unknown), 2b is skipped.
+// In step 3, the fallback charsets tried in step 2 are not tried. We
+// can consider doing that later.
+//
+// When a param value is ASCII, but is not in format #1 or format #3 above,
+// it is returned as it is unless it's pretty close to two supported
// formats but not well-formed. In that case, an empty string is returned.
//
// In any case, a caller must check for the empty return value and resort to
@@ -90,7 +98,8 @@
// other caller is a unit test. Need to figure out expose this function only to
// net_util_unittest.
//
-std::wstring GetFileNameFromCD(const std::string& header);
+std::wstring GetFileNameFromCD(const std::string& header,
+ const std::string& referrer_charset);
// Converts the given host name to unicode characters, APPENDING them to the
// the given output string. This can be called for any host name, if the
@@ -133,16 +142,14 @@
// Gets the filename from the raw Content-Disposition header (as read from the
// network). Otherwise uses the last path component name or hostname from
// |url|. Note: it's possible for the suggested filename to be empty (e.g.,
-// file:/// or view-cache:).
+// file:/// or view-cache:). referrer_charset is used as one of charsets
+// to interpret a raw 8bit string in C-D header (after interpreting
+// as UTF-8 fails). See the comment for GetFilenameFromCD for more details.
std::wstring GetSuggestedFilename(const GURL& url,
const std::string& content_disposition,
+ const std::string& referrer_charset,
const std::wstring& default_name);
-// DEPRECATED: Please use the above version of this method.
-std::wstring GetSuggestedFilename(const GURL& url,
- const std::wstring& content_disposition,
- const std::wstring& default_name);
-
// Checks the given port against a list of ports which are restricted by
// default. Returns true if the port is allowed, false if it is restricted.
bool IsPortAllowedByDefault(int port);
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | net/base/net_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698