OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // by other applications. | 86 // by other applications. |
87 SPACES = 2, | 87 SPACES = 2, |
88 | 88 |
89 // Unescapes various characters that will change the meaning of URLs, | 89 // Unescapes various characters that will change the meaning of URLs, |
90 // including '%', '+', '&', '/', '#'. If we unescaped these characters, the | 90 // including '%', '+', '&', '/', '#'. If we unescaped these characters, the |
91 // resulting URL won't be the same as the source one. This flag is used when | 91 // resulting URL won't be the same as the source one. This flag is used when |
92 // generating final output like filenames for URLs where we won't be | 92 // generating final output like filenames for URLs where we won't be |
93 // interpreting as a URL and want to do as much unescaping as possible. | 93 // interpreting as a URL and want to do as much unescaping as possible. |
94 URL_SPECIAL_CHARS = 4, | 94 URL_SPECIAL_CHARS = 4, |
95 | 95 |
| 96 // Subset of "URL_SPECIAL_CHARS" - excludes '/' and '\\'. For use with file |
| 97 // URLs. |
| 98 // TODO(mmenke): Should GURL unescape those two characters for file URLs? |
| 99 // that's what FireFox and IE do. |
| 100 URL_SPECIAL_CHARS_EXCEPT_PATH_SEPERATORS = 8, |
| 101 |
96 // Unescapes characters that can be used in spoofing attempts (such as LOCK) | 102 // Unescapes characters that can be used in spoofing attempts (such as LOCK) |
97 // and control characters (such as BiDi control characters and %01). This | 103 // and control characters (such as BiDi control characters and %01). This |
98 // INCLUDES NULLs. This is used for rare cases such as data: URL decoding | 104 // INCLUDES NULLs. This is used for rare cases such as data: URL decoding |
99 // where the result is binary data. | 105 // where the result is binary data. |
100 // | 106 // |
101 // DO NOT use SPOOFING_AND_CONTROL_CHARS if the URL is going to be displayed | 107 // DO NOT use SPOOFING_AND_CONTROL_CHARS if the URL is going to be displayed |
102 // in the UI for security reasons. | 108 // in the UI for security reasons. |
103 SPOOFING_AND_CONTROL_CHARS = 8, | 109 SPOOFING_AND_CONTROL_CHARS = 16, |
104 | 110 |
105 // URL queries use "+" for space. This flag controls that replacement. | 111 // URL queries use "+" for space. This flag controls that replacement. |
106 REPLACE_PLUS_WITH_SPACE = 16, | 112 REPLACE_PLUS_WITH_SPACE = 32, |
107 }; | 113 }; |
108 }; | 114 }; |
109 | 115 |
110 // Unescapes |escaped_text| and returns the result. | 116 // Unescapes |escaped_text| and returns the result. |
111 // Unescaping consists of looking for the exact pattern "%XX", where each X is | 117 // Unescaping consists of looking for the exact pattern "%XX", where each X is |
112 // a hex digit, and converting to the character with the numerical value of | 118 // a hex digit, and converting to the character with the numerical value of |
113 // those digits. Thus "i%20=%203%3b" unescapes to "i = 3;". | 119 // those digits. Thus "i%20=%203%3b" unescapes to "i = 3;". |
114 // | 120 // |
115 // Watch out: this doesn't necessarily result in the correct final result, | 121 // Watch out: this doesn't necessarily result in the correct final result, |
116 // because the encoding may be unknown. For example, the input might be ASCII, | 122 // because the encoding may be unknown. For example, the input might be ASCII, |
(...skipping 20 matching lines...) Expand all Loading... |
137 UnescapeRule::Type rules, | 143 UnescapeRule::Type rules, |
138 base::OffsetAdjuster::Adjustments* adjustments); | 144 base::OffsetAdjuster::Adjustments* adjustments); |
139 | 145 |
140 // Unescapes the following ampersand character codes from |text|: | 146 // Unescapes the following ampersand character codes from |text|: |
141 // < > & " ' | 147 // < > & " ' |
142 NET_EXPORT base::string16 UnescapeForHTML(const base::string16& text); | 148 NET_EXPORT base::string16 UnescapeForHTML(const base::string16& text); |
143 | 149 |
144 } // namespace net | 150 } // namespace net |
145 | 151 |
146 #endif // NET_BASE_ESCAPE_H_ | 152 #endif // NET_BASE_ESCAPE_H_ |
OLD | NEW |