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

Side by Side Diff: net/base/escape.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 | « chrome/browser/views/shelf_item_dialog.cc ('k') | net/base/escape.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_ESCAPE_H__ 5 #ifndef NET_BASE_ESCAPE_H__
6 #define NET_BASE_ESCAPE_H__ 6 #define NET_BASE_ESCAPE_H__
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 23 matching lines...) Expand all
34 34
35 // Unescaping ------------------------------------------------------------------ 35 // Unescaping ------------------------------------------------------------------
36 36
37 class UnescapeRule { 37 class UnescapeRule {
38 public: 38 public:
39 // A combination of the following flags that is passed to the unescaping 39 // A combination of the following flags that is passed to the unescaping
40 // functions. 40 // functions.
41 typedef uint32 Type; 41 typedef uint32 Type;
42 42
43 enum { 43 enum {
44 // Don't unescape anything at all.
45 NONE = 0,
46
44 // Don't unescape anything special, but all normal unescaping will happen. 47 // Don't unescape anything special, but all normal unescaping will happen.
45 // This is a placeholder and can't be combined with other flags (since it's 48 // This is a placeholder and can't be combined with other flags (since it's
46 // just the absense of them). Things like escaped letters, digits, and most 49 // just the absence of them). All other unescape rules imply "normal" in
47 // symbols will get unescaped with this mode. 50 // addition to their special meaning. Things like escaped letters, digits,
48 NORMAL = 0, 51 // and most symbols will get unescaped with this mode.
52 NORMAL = 1,
49 53
50 // Convert %20 to spaces. In some places where we're showing URLs, we may 54 // Convert %20 to spaces. In some places where we're showing URLs, we may
51 // want this. In places where the URL may be copied and pasted out, then 55 // want this. In places where the URL may be copied and pasted out, then
52 // you wouldn't want this since it might not be interpreted in one piece 56 // you wouldn't want this since it might not be interpreted in one piece
53 // by other applications. 57 // by other applications.
54 SPACES = 1, 58 SPACES = 2,
55 59
56 // Unescapes various characters that will change the meaning of URLs, 60 // Unescapes various characters that will change the meaning of URLs,
57 // including '%', '+', '&', '/', '#'. If we unescaped these charaters, the 61 // including '%', '+', '&', '/', '#'. If we unescaped these characters, the
58 // resulting URL won't be the same as the source one. This flag is used when 62 // resulting URL won't be the same as the source one. This flag is used when
59 // generating final output like filenames for URLs where we won't be 63 // generating final output like filenames for URLs where we won't be
60 // interpreting as a URL and want to do as much unescaping as possible. 64 // interpreting as a URL and want to do as much unescaping as possible.
61 URL_SPECIAL_CHARS = 2, 65 URL_SPECIAL_CHARS = 4,
62 66
63 // Unescapes control characters such as %01. This INCLUDES NULLs!. This is 67 // Unescapes control characters such as %01. This INCLUDES NULLs. This is
64 // used for rare cases such as data: URL decoding where the result is binary 68 // used for rare cases such as data: URL decoding where the result is binary
65 // data. You should not use this for normal URLs! 69 // data. You should not use this for normal URLs!
66 CONTROL_CHARS = 4, 70 CONTROL_CHARS = 8,
67 71
68 // URL queries use "+" for space. This flag controls that replacement. 72 // URL queries use "+" for space. This flag controls that replacement.
69 REPLACE_PLUS_WITH_SPACE = 8, 73 REPLACE_PLUS_WITH_SPACE = 16,
70 }; 74 };
71 }; 75 };
72 76
73 // Unescapes |escaped_text| and returns the result. 77 // Unescapes |escaped_text| and returns the result.
74 // Unescaping consists of looking for the exact pattern "%XX", where each X is 78 // Unescaping consists of looking for the exact pattern "%XX", where each X is
75 // a hex digit, and converting to the character with the numerical value of 79 // a hex digit, and converting to the character with the numerical value of
76 // those digits. Thus "i%20=%203%3b" unescapes to "i = 3;". 80 // those digits. Thus "i%20=%203%3b" unescapes to "i = 3;".
77 // 81 //
78 // Watch out: this doesn't necessarily result in the correct final result, 82 // Watch out: this doesn't necessarily result in the correct final result,
79 // because the encoding may be unknown. For example, the input might be ASCII, 83 // because the encoding may be unknown. For example, the input might be ASCII,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 std::wstring* escaped); 115 std::wstring* escaped);
112 116
113 // A specialized version of EscapeQueryParamValue for wide strings that 117 // A specialized version of EscapeQueryParamValue for wide strings that
114 // assumes the codepage is UTF8. This is provided as a convenience. 118 // assumes the codepage is UTF8. This is provided as a convenience.
115 // 119 //
116 // TODO(brettw) bug 1201094: This function should be removed. See the bug for 120 // TODO(brettw) bug 1201094: This function should be removed. See the bug for
117 // why and what callers should do instead. 121 // why and what callers should do instead.
118 std::wstring EscapeQueryParamValueUTF8(const std::wstring& text); 122 std::wstring EscapeQueryParamValueUTF8(const std::wstring& text);
119 123
120 #endif // #ifndef NET_BASE_ESCAPE_H__ 124 #endif // #ifndef NET_BASE_ESCAPE_H__
OLDNEW
« no previous file with comments | « chrome/browser/views/shelf_item_dialog.cc ('k') | net/base/escape.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698