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

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

Issue 56053: URL's not properly unescaping when displayed (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 6 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') | net/base/net_util.h » ('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) 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/string_util.h" 10 #include "base/string_util.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 "%7B%7C%7D~%7F%80%FF"); 107 "%7B%7C%7D~%7F%80%FF");
108 } 108 }
109 109
110 TEST(Escape, UnescapeURLComponent) { 110 TEST(Escape, UnescapeURLComponent) {
111 const UnescapeURLCase unescape_cases[] = { 111 const UnescapeURLCase unescape_cases[] = {
112 {"", UnescapeRule::NORMAL, ""}, 112 {"", UnescapeRule::NORMAL, ""},
113 {"%2", UnescapeRule::NORMAL, "%2"}, 113 {"%2", UnescapeRule::NORMAL, "%2"},
114 {"%%%%%%", UnescapeRule::NORMAL, "%%%%%%"}, 114 {"%%%%%%", UnescapeRule::NORMAL, "%%%%%%"},
115 {"Don't escape anything", UnescapeRule::NORMAL, "Don't escape anything"}, 115 {"Don't escape anything", UnescapeRule::NORMAL, "Don't escape anything"},
116 {"Invalid %escape %2", UnescapeRule::NORMAL, "Invalid %escape %2"}, 116 {"Invalid %escape %2", UnescapeRule::NORMAL, "Invalid %escape %2"},
117 {"Some%20random text %25%3bOK", UnescapeRule::NONE,
118 "Some%20random text %25%3bOK"},
117 {"Some%20random text %25%3bOK", UnescapeRule::NORMAL, 119 {"Some%20random text %25%3bOK", UnescapeRule::NORMAL,
118 "Some%20random text %25;OK"}, 120 "Some%20random text %25;OK"},
119 {"Some%20random text %25%3bOK", UnescapeRule::SPACES, 121 {"Some%20random text %25%3bOK", UnescapeRule::SPACES,
120 "Some random text %25;OK"}, 122 "Some random text %25;OK"},
121 {"Some%20random text %25%3bOK", UnescapeRule::URL_SPECIAL_CHARS, 123 {"Some%20random text %25%3bOK", UnescapeRule::URL_SPECIAL_CHARS,
122 "Some%20random text %;OK"}, 124 "Some%20random text %;OK"},
123 {"Some%20random text %25%3bOK", 125 {"Some%20random text %25%3bOK",
124 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, 126 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS,
125 "Some random text %;OK"}, 127 "Some random text %;OK"},
126 {"%A0%B1%C2%D3%E4%F5", UnescapeRule::NORMAL, "\xA0\xB1\xC2\xD3\xE4\xF5"}, 128 {"%A0%B1%C2%D3%E4%F5", UnescapeRule::NORMAL, "\xA0\xB1\xC2\xD3\xE4\xF5"},
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 const EscapeForHTMLCase tests[] = { 225 const EscapeForHTMLCase tests[] = {
224 { "hello", "hello" }, 226 { "hello", "hello" },
225 { "<hello>", "&lt;hello&gt;" }, 227 { "<hello>", "&lt;hello&gt;" },
226 { "don\'t mess with me", "don&#39;t mess with me" }, 228 { "don\'t mess with me", "don&#39;t mess with me" },
227 }; 229 };
228 for (size_t i = 0; i < arraysize(tests); ++i) { 230 for (size_t i = 0; i < arraysize(tests); ++i) {
229 std::string result = EscapeForHTML(std::string(tests[i].input)); 231 std::string result = EscapeForHTML(std::string(tests[i].input));
230 EXPECT_EQ(std::string(tests[i].expected_output), result); 232 EXPECT_EQ(std::string(tests[i].expected_output), result);
231 } 233 }
232 } 234 }
OLDNEW
« no previous file with comments | « net/base/escape.cc ('k') | net/base/net_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698