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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // by other applications. | 85 // by other applications. |
86 SPACES = 2, | 86 SPACES = 2, |
87 | 87 |
88 // Unescapes various characters that will change the meaning of URLs, | 88 // Unescapes various characters that will change the meaning of URLs, |
89 // including '%', '+', '&', '/', '#'. If we unescaped these characters, the | 89 // including '%', '+', '&', '/', '#'. If we unescaped these characters, the |
90 // resulting URL won't be the same as the source one. This flag is used when | 90 // resulting URL won't be the same as the source one. This flag is used when |
91 // generating final output like filenames for URLs where we won't be | 91 // generating final output like filenames for URLs where we won't be |
92 // interpreting as a URL and want to do as much unescaping as possible. | 92 // interpreting as a URL and want to do as much unescaping as possible. |
93 URL_SPECIAL_CHARS = 4, | 93 URL_SPECIAL_CHARS = 4, |
94 | 94 |
95 // Unescapes control characters such as %01. This INCLUDES NULLs. This is | 95 // Unescapes characters that can be used in spoofing attempts (such as LOCK) |
96 // used for rare cases such as data: URL decoding where the result is binary | 96 // and control characters (such as BiDi control characters and %01). This |
97 // data. This flag also unescapes BiDi control characters. | 97 // INCLUDES NULLs. This is used for rare cases such as data: URL decoding |
| 98 // where the result is binary data. |
98 // | 99 // |
99 // DO NOT use CONTROL_CHARS if the URL is going to be displayed in the UI | 100 // DO NOT use SPOOFING_AND_CONTROL_CHARS if the URL is going to be displayed |
100 // for security reasons. | 101 // in the UI for security reasons. |
101 CONTROL_CHARS = 8, | 102 SPOOFING_AND_CONTROL_CHARS = 8, |
102 | 103 |
103 // URL queries use "+" for space. This flag controls that replacement. | 104 // URL queries use "+" for space. This flag controls that replacement. |
104 REPLACE_PLUS_WITH_SPACE = 16, | 105 REPLACE_PLUS_WITH_SPACE = 16, |
105 }; | 106 }; |
106 }; | 107 }; |
107 | 108 |
108 // Unescapes |escaped_text| and returns the result. | 109 // Unescapes |escaped_text| and returns the result. |
109 // Unescaping consists of looking for the exact pattern "%XX", where each X is | 110 // Unescaping consists of looking for the exact pattern "%XX", where each X is |
110 // a hex digit, and converting to the character with the numerical value of | 111 // a hex digit, and converting to the character with the numerical value of |
111 // those digits. Thus "i%20=%203%3b" unescapes to "i = 3;". | 112 // those digits. Thus "i%20=%203%3b" unescapes to "i = 3;". |
(...skipping 23 matching lines...) Expand all Loading... |
135 UnescapeRule::Type rules, | 136 UnescapeRule::Type rules, |
136 base::OffsetAdjuster::Adjustments* adjustments); | 137 base::OffsetAdjuster::Adjustments* adjustments); |
137 | 138 |
138 // Unescapes the following ampersand character codes from |text|: | 139 // Unescapes the following ampersand character codes from |text|: |
139 // < > & " ' | 140 // < > & " ' |
140 NET_EXPORT base::string16 UnescapeForHTML(const base::string16& text); | 141 NET_EXPORT base::string16 UnescapeForHTML(const base::string16& text); |
141 | 142 |
142 } // namespace net | 143 } // namespace net |
143 | 144 |
144 #endif // NET_BASE_ESCAPE_H_ | 145 #endif // NET_BASE_ESCAPE_H_ |
OLD | NEW |