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

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

Issue 548088: Adding some more escaping method.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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 | « no previous file | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // a hex digit, and converting to the character with the numerical value of 85 // a hex digit, and converting to the character with the numerical value of
86 // those digits. Thus "i%20=%203%3b" unescapes to "i = 3;". 86 // those digits. Thus "i%20=%203%3b" unescapes to "i = 3;".
87 // 87 //
88 // Watch out: this doesn't necessarily result in the correct final result, 88 // Watch out: this doesn't necessarily result in the correct final result,
89 // because the encoding may be unknown. For example, the input might be ASCII, 89 // because the encoding may be unknown. For example, the input might be ASCII,
90 // which, after unescaping, is supposed to be interpreted as UTF-8, and then 90 // which, after unescaping, is supposed to be interpreted as UTF-8, and then
91 // converted into full wide chars. This function won't tell you if any 91 // converted into full wide chars. This function won't tell you if any
92 // conversions need to take place, it only unescapes. 92 // conversions need to take place, it only unescapes.
93 std::string UnescapeURLComponent(const std::string& escaped_text, 93 std::string UnescapeURLComponent(const std::string& escaped_text,
94 UnescapeRule::Type rules); 94 UnescapeRule::Type rules);
95 string16 UnescapeURLComponent(const string16& escaped_text,
96 UnescapeRule::Type rules);
95 97
96 // Unescapes the given substring as a URL, and then tries to interpret the 98 // Unescapes the given substring as a URL, and then tries to interpret the
97 // result as being encoded as UTF-8. If the result is convertable into UTF-8, it 99 // result as being encoded as UTF-8. If the result is convertable into UTF-8, it
98 // will be returned as converted. If it is not, the original escaped string will 100 // will be returned as converted. If it is not, the original escaped string will
99 // be converted into a string16 and returned. 101 // be converted into a string16 and returned.
100 // 102 //
101 // |offset_for_adjustment| may be NULL; if not, it is an offset into |text| that 103 // |offset_for_adjustment| may be NULL; if not, it is an offset into |text| that
102 // will be adjusted to point at the same logical place in the result string. If 104 // will be adjusted to point at the same logical place in the result string. If
103 // this isn't possible because it points into the middle of an escape sequence 105 // this isn't possible because it points into the middle of an escape sequence
104 // or past the end of the string, it will be set to string16::npos. 106 // or past the end of the string, it will be set to string16::npos.
105 string16 UnescapeAndDecodeUTF8URLComponent(const std::string& text, 107 string16 UnescapeAndDecodeUTF8URLComponent(const std::string& text,
106 UnescapeRule::Type rules, 108 UnescapeRule::Type rules,
107 size_t* offset_for_adjustment); 109 size_t* offset_for_adjustment);
108 110
111 // Unescape the following ampersand character codes from |text|:
112 // &lt; &gt; &amp; &quot; &#39;
113 string16 UnescapeForHTML(const string16& text);
114
109 // Deprecated ------------------------------------------------------------------ 115 // Deprecated ------------------------------------------------------------------
110 116
111 // Escapes characters in text suitable for use as a query parameter value. 117 // Escapes characters in text suitable for use as a query parameter value.
112 // We %XX everything except alphanumerics and -_.!~*'() 118 // We %XX everything except alphanumerics and -_.!~*'()
113 // Spaces change to "+" unless you pass usePlus=false. 119 // Spaces change to "+" unless you pass usePlus=false.
114 // This is basically the same as encodeURIComponent in javascript. 120 // This is basically the same as encodeURIComponent in javascript.
115 // For the string16 version, we do a conversion to charset before encoding the 121 // For the string16 version, we do a conversion to charset before encoding the
116 // string. If the charset doesn't exist, we return false. 122 // string. If the charset doesn't exist, we return false.
117 // 123 //
118 // TODO(brettw) bug 1201094: This function should be removed. See the bug for 124 // TODO(brettw) bug 1201094: This function should be removed. See the bug for
119 // why and what callers should do instead. 125 // why and what callers should do instead.
120 std::string EscapeQueryParamValue(const std::string& text); 126 std::string EscapeQueryParamValue(const std::string& text);
121 std::string EscapeQueryParamValue(const std::string& text, bool use_plus); 127 std::string EscapeQueryParamValue(const std::string& text, bool use_plus);
122 bool EscapeQueryParamValue(const string16& text, const char* codepage, 128 bool EscapeQueryParamValue(const string16& text, const char* codepage,
123 string16* escaped); 129 string16* escaped);
124 130
125 // A specialized version of EscapeQueryParamValue for wide strings that 131 // A specialized version of EscapeQueryParamValue for wide strings that
126 // assumes the codepage is UTF8. This is provided as a convenience. 132 // assumes the codepage is UTF8. This is provided as a convenience.
127 // 133 //
128 // TODO(brettw) bug 1201094: This function should be removed. See the bug for 134 // TODO(brettw) bug 1201094: This function should be removed. See the bug for
129 // why and what callers should do instead. 135 // why and what callers should do instead.
130 std::wstring EscapeQueryParamValueUTF8(const std::wstring& text); 136 std::wstring EscapeQueryParamValueUTF8(const std::wstring& text);
131 137
132 #endif // #ifndef NET_BASE_ESCAPE_H__ 138 #endif // #ifndef NET_BASE_ESCAPE_H__
OLDNEW
« no previous file with comments | « no previous file | net/base/escape.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698