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

Side by Side Diff: net/base/escape_unittest.cc

Issue 408: Fix an out of band read when parsing a URL component of just "%". The... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 3 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 | « net/base/escape.cc ('k') | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include <string> 5 #include <string>
6 6
7 #include "net/base/escape.h" 7 #include "net/base/escape.h"
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 // When we're not unescaping NULLs. 153 // When we're not unescaping NULLs.
154 expected = "Null"; 154 expected = "Null";
155 expected.push_back(0); 155 expected.push_back(0);
156 expected.append("%009Test"); 156 expected.append("%009Test");
157 EXPECT_EQ(expected, UnescapeURLComponent(input, UnescapeRule::NORMAL)); 157 EXPECT_EQ(expected, UnescapeURLComponent(input, UnescapeRule::NORMAL));
158 } 158 }
159 159
160 TEST(Escape, UnescapeAndDecodeURLComponent) { 160 TEST(Escape, UnescapeAndDecodeURLComponent) {
161 const UnescapeAndDecodeURLCase unescape_cases[] = { 161 const UnescapeAndDecodeURLCase unescape_cases[] = {
162 {"UTF8", "%", "%", "%", L"%"},
162 {"UTF8", "+", "+", " ", L"+"}, 163 {"UTF8", "+", "+", " ", L"+"},
163 {"UTF8", "%2+", "%2+", "%2 ", L"%2+"}, 164 {"UTF8", "%2+", "%2+", "%2 ", L"%2+"},
164 {"UTF8", "+%%%+%%%", "+%%%+%%%", " %%% %%%", L"+%%%+%%%"}, 165 {"UTF8", "+%%%+%%%", "+%%%+%%%", " %%% %%%", L"+%%%+%%%"},
165 {"UTF8", "Don't escape anything", 166 {"UTF8", "Don't escape anything",
166 "Don't escape anything", 167 "Don't escape anything",
167 "Don't escape anything", 168 "Don't escape anything",
168 L"Don't escape anything"}, 169 L"Don't escape anything"},
169 {"UTF8", "+Invalid %escape %2+", 170 {"UTF8", "+Invalid %escape %2+",
170 "+Invalid %escape %2+", 171 "+Invalid %escape %2+",
171 " Invalid %escape %2 ", 172 " Invalid %escape %2 ",
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 { "<hello>", "&lt;hello&gt;" }, 216 { "<hello>", "&lt;hello&gt;" },
216 { "don\'t mess with me", "don&#39;t mess with me" }, 217 { "don\'t mess with me", "don&#39;t mess with me" },
217 }; 218 };
218 for (size_t i = 0; i < arraysize(tests); ++i) { 219 for (size_t i = 0; i < arraysize(tests); ++i) {
219 std::string result = EscapeForHTML(std::string(tests[i].input)); 220 std::string result = EscapeForHTML(std::string(tests[i].input));
220 EXPECT_EQ(std::string(tests[i].expected_output), result); 221 EXPECT_EQ(std::string(tests[i].expected_output), result);
221 } 222 }
222 } 223 }
223 224
224 225
OLDNEW
« no previous file with comments | « net/base/escape.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698