| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 223 const EscapeForHTMLCase tests[] = { | 225 const EscapeForHTMLCase tests[] = { |
| 224 { "hello", "hello" }, | 226 { "hello", "hello" }, |
| 225 { "<hello>", "<hello>" }, | 227 { "<hello>", "<hello>" }, |
| 226 { "don\'t mess with me", "don't mess with me" }, | 228 { "don\'t mess with me", "don'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 } |
| OLD | NEW |