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> |
11 | 11 |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 #include "base/strings/utf_offset_string_conversions.h" | 14 #include "base/strings/utf_offset_string_conversions.h" |
15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 // Escaping -------------------------------------------------------------------- | 19 // Escaping -------------------------------------------------------------------- |
20 | 20 |
21 // Escapes characters in text suitable for use as a query parameter value. | 21 // Escapes characters in text suitable for use as a query parameter value. |
22 // We %XX everything except alphanumerics and -_.!~*'() | 22 // We %XX everything except alphanumerics and -_.!~*'() |
23 // Spaces change to "+" unless you pass usePlus=false. | 23 // Spaces change to "+" unless you pass usePlus=false. |
24 // This is basically the same as encodeURIComponent in javascript. | 24 // This is basically the same as encodeURIComponent in javascript. |
25 NET_EXPORT std::string EscapeQueryParamValue(base::StringPiece text, | 25 NET_EXPORT std::string EscapeQueryParamValue(base::StringPiece text, |
26 bool use_plus); | 26 bool use_plus); |
27 | 27 |
28 // Escapes a partial or complete file/pathname. This includes: | 28 // Escapes a partial or complete file/pathname. This includes: |
29 // non-printable, non-7bit, and (including space) "#%:<>?[\]^`{|} | 29 // non-printable, non-7bit, and (including space) "#%:<>?[\]^`{|} |
30 // For the base::string16 version, we attempt a conversion to |codepage| before | |
31 // encoding the string. If this conversion fails, we return false. | |
32 NET_EXPORT std::string EscapePath(base::StringPiece path); | 30 NET_EXPORT std::string EscapePath(base::StringPiece path); |
33 | 31 |
34 #if defined(OS_MACOSX) | 32 #if defined(OS_MACOSX) |
35 // Escapes characters as per expectations of NSURL. This includes: | 33 // Escapes characters as per expectations of NSURL. This includes: |
36 // non-printable, non-7bit, and (including space) "#%<>[\]^`{|} | 34 // non-printable, non-7bit, and (including space) "#%<>[\]^`{|} |
37 NET_EXPORT std::string EscapeNSURLPrecursor(base::StringPiece precursor); | 35 NET_EXPORT std::string EscapeNSURLPrecursor(base::StringPiece precursor); |
38 #endif // defined(OS_MACOSX) | 36 #endif // defined(OS_MACOSX) |
39 | 37 |
40 // Escapes application/x-www-form-urlencoded content. This includes: | 38 // Escapes application/x-www-form-urlencoded content. This includes: |
41 // non-printable, non-7bit, and (including space) ?>=<;+'&%$#"![\]^`{|} | 39 // non-printable, non-7bit, and (including space) ?>=<;+'&%$#"![\]^`{|} |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 UnescapeRule::Type rules, | 142 UnescapeRule::Type rules, |
145 base::OffsetAdjuster::Adjustments* adjustments); | 143 base::OffsetAdjuster::Adjustments* adjustments); |
146 | 144 |
147 // Unescapes the following ampersand character codes from |text|: | 145 // Unescapes the following ampersand character codes from |text|: |
148 // < > & " ' | 146 // < > & " ' |
149 NET_EXPORT base::string16 UnescapeForHTML(base::StringPiece16 text); | 147 NET_EXPORT base::string16 UnescapeForHTML(base::StringPiece16 text); |
150 | 148 |
151 } // namespace net | 149 } // namespace net |
152 | 150 |
153 #endif // NET_BASE_ESCAPE_H_ | 151 #endif // NET_BASE_ESCAPE_H_ |
OLD | NEW |