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

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

Issue 643963004: Unescape BiDi control chars while parsing data urls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test comment Created 6 years, 2 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
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // interpreting as a URL and want to do as much unescaping as possible. 86 // interpreting as a URL and want to do as much unescaping as possible.
87 URL_SPECIAL_CHARS = 4, 87 URL_SPECIAL_CHARS = 4,
88 88
89 // Unescapes control characters such as %01. This INCLUDES NULLs. This is 89 // Unescapes control characters such as %01. This INCLUDES NULLs. This is
90 // used for rare cases such as data: URL decoding where the result is binary 90 // used for rare cases such as data: URL decoding where the result is binary
91 // data. You should not use this for normal URLs! 91 // data. You should not use this for normal URLs!
92 CONTROL_CHARS = 8, 92 CONTROL_CHARS = 8,
93 93
94 // URL queries use "+" for space. This flag controls that replacement. 94 // URL queries use "+" for space. This flag controls that replacement.
95 REPLACE_PLUS_WITH_SPACE = 16, 95 REPLACE_PLUS_WITH_SPACE = 16,
96
97 // Unescapes Bidi characters such as RTL/LTR marks. This should only be used
98 // when parsing data urls, but never be used when displaying the url in
99 // the omnibox. URLs in the omnibox should always escape BiDi control
100 // characters for security reasons.
101 // DO NOT use BIDI_CONTROL_CHARS flag without talking to a security person.
102 BIDI_CONTROL_CHARS = 32,
96 }; 103 };
97 }; 104 };
98 105
99 // Unescapes |escaped_text| and returns the result. 106 // Unescapes |escaped_text| and returns the result.
100 // Unescaping consists of looking for the exact pattern "%XX", where each X is 107 // Unescaping consists of looking for the exact pattern "%XX", where each X is
101 // a hex digit, and converting to the character with the numerical value of 108 // a hex digit, and converting to the character with the numerical value of
102 // those digits. Thus "i%20=%203%3b" unescapes to "i = 3;". 109 // those digits. Thus "i%20=%203%3b" unescapes to "i = 3;".
103 // 110 //
104 // Watch out: this doesn't necessarily result in the correct final result, 111 // Watch out: this doesn't necessarily result in the correct final result,
105 // because the encoding may be unknown. For example, the input might be ASCII, 112 // because the encoding may be unknown. For example, the input might be ASCII,
(...skipping 20 matching lines...) Expand all
126 UnescapeRule::Type rules, 133 UnescapeRule::Type rules,
127 base::OffsetAdjuster::Adjustments* adjustments); 134 base::OffsetAdjuster::Adjustments* adjustments);
128 135
129 // Unescapes the following ampersand character codes from |text|: 136 // Unescapes the following ampersand character codes from |text|:
130 // &lt; &gt; &amp; &quot; &#39; 137 // &lt; &gt; &amp; &quot; &#39;
131 NET_EXPORT base::string16 UnescapeForHTML(const base::string16& text); 138 NET_EXPORT base::string16 UnescapeForHTML(const base::string16& text);
132 139
133 } // namespace net 140 } // namespace net
134 141
135 #endif // NET_BASE_ESCAPE_H_ 142 #endif // NET_BASE_ESCAPE_H_
OLDNEW
« no previous file with comments | « net/base/data_url_unittest.cc ('k') | net/base/escape.cc » ('j') | net/base/escape.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698