diff options
author | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-03 02:16:32 +0000 |
---|---|---|
committer | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-03 02:16:32 +0000 |
commit | a23de85783d944cbb75f09737eb29c60ea87481d (patch) | |
tree | 30c4732b42443259134a3f83f574bfaa2a506292 /net/base/net_util.h | |
parent | 1b5237ecc1fea39e51e1634acbcdf11bd7ef57b0 (diff) | |
download | chromium_src-a23de85783d944cbb75f09737eb29c60ea87481d.zip chromium_src-a23de85783d944cbb75f09737eb29c60ea87481d.tar.gz chromium_src-a23de85783d944cbb75f09737eb29c60ea87481d.tar.bz2 |
Local text file with spaces in filename is urlencoded in tab title
When viewing a local text file with spaces in filename, it is still urlencoded. Filename should be displayed with spaces, not with urlencoding. It would be more user-friendly.
Since net::FormatURL is already implemented, using it would be great. But it doesn't escape SPACES, just NORMAL, it doesn't even escape unicode. I plumbed out a unescapeurl that could be used whether we allow conversion of spaces or not.
BUG=8775 (http://crbug.com/8775)
TEST=Tested whether the input is escaped in the navigational context and ran the net tests
New Review: http://codereview.chromium.org/118059
Review URL: http://codereview.chromium.org/56053
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17462 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_util.h')
-rw-r--r-- | net/base/net_util.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/net/base/net_util.h b/net/base/net_util.h index 2ab6101..d7f1de7 100644 --- a/net/base/net_util.h +++ b/net/base/net_util.h @@ -14,6 +14,7 @@ #include <string> #include "base/basictypes.h" +#include "net/base/escape.h" struct addrinfo; class FilePath; @@ -184,23 +185,25 @@ void AppendFormattedHost(const GURL& url, const std::wstring& languages, // Creates a string representation of |url|. The IDN host name may // be in Unicode if |languages| accepts the Unicode representation. // If |omit_username_password| is true, the username and the password are -// omitted. If |unescape| is true and the path part and the query part seem to -// be encoded in %-encoded UTF-8, decodes %-encoding and UTF-8. -// |new_parsed| will have parsing parameters of the resultant URL. |prefix_end| -// will be the length before the hostname of the resultant URL. |new_parsed| -// and |prefix_end| may be NULL. +// omitted. |unescape_rules| defines how to clean the URL for human readability. +// You will generally want |UnescapeRule::SPACES| for display to the user if you +// can handle spaces, or |UnescapeRule::NORMAL| if not. If the path part and the +// query part seem to be encoded in %-encoded UTF-8, decodes %-encoding and +// UTF-8. |new_parsed| will have parsing parameters of the resultant URL. +// |prefix_end| will be the length before the hostname of the resultant URL. +// |new_parsed| and |prefix_end| may be NULL. std::wstring FormatUrl(const GURL& url, const std::wstring& languages, bool omit_username_password, - bool unescape, + UnescapeRule::Type unescape_rules, url_parse::Parsed* new_parsed, size_t* prefix_end); // Creates a string representation of |url| for display to the user. // This is a shorthand of the above function with omit_username_password=true, -// unescape=true, new_parsed=NULL, and prefix_end=NULL. +// unescape=SPACES, new_parsed=NULL, and prefix_end=NULL. inline std::wstring FormatUrl(const GURL& url, const std::wstring& languages) { - return FormatUrl(url, languages, true, true, NULL, NULL); + return FormatUrl(url, languages, true, UnescapeRule::SPACES, NULL, NULL); } } // namespace net |