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

Side by Side Diff: net/base/net_util.h

Issue 56053: URL's not properly unescaping when displayed (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/escape_unittest.cc ('k') | net/base/net_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_BASE_NET_UTIL_H__ 5 #ifndef NET_BASE_NET_UTIL_H__
6 #define NET_BASE_NET_UTIL_H__ 6 #define NET_BASE_NET_UTIL_H__
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #ifdef OS_WIN 10 #ifdef OS_WIN
11 #include <windows.h> 11 #include <windows.h>
12 #endif 12 #endif
13 13
14 #include <string> 14 #include <string>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "net/base/escape.h"
17 18
18 struct addrinfo; 19 struct addrinfo;
19 class FilePath; 20 class FilePath;
20 class GURL; 21 class GURL;
21 22
22 namespace base { 23 namespace base {
23 class Time; 24 class Time;
24 } 25 }
25 26
26 namespace url_parse { 27 namespace url_parse {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // Appends the given part of the original URL to the output string formatted for 178 // Appends the given part of the original URL to the output string formatted for
178 // the user. The given parsed structure will be updated. The host name formatter 179 // the user. The given parsed structure will be updated. The host name formatter
179 // also takes the same accept languages component as ElideURL. |new_parsed| may 180 // also takes the same accept languages component as ElideURL. |new_parsed| may
180 // be null. 181 // be null.
181 void AppendFormattedHost(const GURL& url, const std::wstring& languages, 182 void AppendFormattedHost(const GURL& url, const std::wstring& languages,
182 std::wstring* output, url_parse::Parsed* new_parsed); 183 std::wstring* output, url_parse::Parsed* new_parsed);
183 184
184 // Creates a string representation of |url|. The IDN host name may 185 // Creates a string representation of |url|. The IDN host name may
185 // be in Unicode if |languages| accepts the Unicode representation. 186 // be in Unicode if |languages| accepts the Unicode representation.
186 // If |omit_username_password| is true, the username and the password are 187 // If |omit_username_password| is true, the username and the password are
187 // omitted. If |unescape| is true and the path part and the query part seem to 188 // omitted. |unescape_rules| defines how to clean the URL for human readability.
188 // be encoded in %-encoded UTF-8, decodes %-encoding and UTF-8. 189 // You will generally want |UnescapeRule::SPACES| for display to the user if you
189 // |new_parsed| will have parsing parameters of the resultant URL. |prefix_end| 190 // can handle spaces, or |UnescapeRule::NORMAL| if not. If the path part and the
190 // will be the length before the hostname of the resultant URL. |new_parsed| 191 // query part seem to be encoded in %-encoded UTF-8, decodes %-encoding and
191 // and |prefix_end| may be NULL. 192 // UTF-8. |new_parsed| will have parsing parameters of the resultant URL.
193 // |prefix_end| will be the length before the hostname of the resultant URL.
194 // |new_parsed| and |prefix_end| may be NULL.
192 std::wstring FormatUrl(const GURL& url, 195 std::wstring FormatUrl(const GURL& url,
193 const std::wstring& languages, 196 const std::wstring& languages,
194 bool omit_username_password, 197 bool omit_username_password,
195 bool unescape, 198 UnescapeRule::Type unescape_rules,
196 url_parse::Parsed* new_parsed, 199 url_parse::Parsed* new_parsed,
197 size_t* prefix_end); 200 size_t* prefix_end);
198 201
199 // Creates a string representation of |url| for display to the user. 202 // Creates a string representation of |url| for display to the user.
200 // This is a shorthand of the above function with omit_username_password=true, 203 // This is a shorthand of the above function with omit_username_password=true,
201 // unescape=true, new_parsed=NULL, and prefix_end=NULL. 204 // unescape=SPACES, new_parsed=NULL, and prefix_end=NULL.
202 inline std::wstring FormatUrl(const GURL& url, const std::wstring& languages) { 205 inline std::wstring FormatUrl(const GURL& url, const std::wstring& languages) {
203 return FormatUrl(url, languages, true, true, NULL, NULL); 206 return FormatUrl(url, languages, true, UnescapeRule::SPACES, NULL, NULL);
204 } 207 }
205 208
206 } // namespace net 209 } // namespace net
207 210
208 #endif // NET_BASE_NET_UTIL_H__ 211 #endif // NET_BASE_NET_UTIL_H__
OLDNEW
« no previous file with comments | « net/base/escape_unittest.cc ('k') | net/base/net_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698