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.cc | |
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.cc')
-rw-r--r-- | net/base/net_util.cc | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc index bfc2cea..3139acb 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -656,11 +656,11 @@ void IDNToUnicodeOneComponent(const char16* comp, namespace net { // Appends the substring |in_component| inside of the URL |spec| to |output|, -// and the resulting range will be filled into |out_component|. Calls the -// unescaper for the substring if |unescape| is true. +// and the resulting range will be filled into |out_component|. |unescape_rules| +// defines how to clean the URL for human readability. static void AppendFormattedComponent(const std::string& spec, const url_parse::Component& in_component, - bool unescape, + UnescapeRule::Type unescape_rules, std::wstring* output, url_parse::Component* out_component); @@ -1084,18 +1084,18 @@ void AppendFormattedHost(const GURL& url, /* static */ void AppendFormattedComponent(const std::string& spec, const url_parse::Component& in_component, - bool unescape, + UnescapeRule::Type unescape_rules, std::wstring* output, url_parse::Component* out_component) { if (in_component.is_nonempty()) { out_component->begin = static_cast<int>(output->length()); - if (unescape) { - output->append(UnescapeAndDecodeUTF8URLComponent( - spec.substr(in_component.begin, in_component.len), - UnescapeRule::NORMAL)); - } else { + if (unescape_rules == UnescapeRule::NONE) { output->append(UTF8ToWide(spec.substr( in_component.begin, in_component.len))); + } else { + output->append(UnescapeAndDecodeUTF8URLComponent( + spec.substr(in_component.begin, in_component.len), + unescape_rules)); } out_component->len = static_cast<int>(output->length()) - out_component->begin; @@ -1104,9 +1104,12 @@ void AppendFormattedComponent(const std::string& spec, } } -std::wstring FormatUrl( - const GURL& url, const std::wstring& languages, bool omit_username_password, - bool unescape, url_parse::Parsed* new_parsed, size_t* prefix_end) { +std::wstring FormatUrl(const GURL& url, + const std::wstring& languages, + bool omit_username_password, + UnescapeRule::Type unescape_rules, + url_parse::Parsed* new_parsed, + size_t* prefix_end) { url_parse::Parsed parsed_temp; if (!new_parsed) new_parsed = &parsed_temp; @@ -1140,12 +1143,14 @@ std::wstring FormatUrl( new_parsed->password.reset(); } else { AppendFormattedComponent( - spec, parsed.username, unescape, &url_string, &new_parsed->username); + spec, parsed.username, unescape_rules, + &url_string, &new_parsed->username); if (parsed.password.is_valid()) { url_string.push_back(':'); } AppendFormattedComponent( - spec, parsed.password, unescape, &url_string, &new_parsed->password); + spec, parsed.password, unescape_rules, + &url_string, &new_parsed->password); if (parsed.username.is_valid() || parsed.password.is_valid()) { url_string.push_back('@'); } @@ -1169,11 +1174,13 @@ std::wstring FormatUrl( // Path and query both get the same general unescape & convert treatment. AppendFormattedComponent( - spec, parsed.path, unescape, &url_string, &new_parsed->path); + spec, parsed.path, unescape_rules, &url_string, + &new_parsed->path); if (parsed.query.is_valid()) url_string.push_back('?'); AppendFormattedComponent( - spec, parsed.query, unescape, &url_string, &new_parsed->query); + spec, parsed.query, unescape_rules, &url_string, + &new_parsed->query); // Reference is stored in valid, unescaped UTF-8, so we can just convert. if (parsed.ref.is_valid()) { |