Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "net/base/escape.h" | 8 #include "net/base/escape.h" |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 { "<", "<" }, | 446 { "<", "<" }, |
| 447 { ">", ">" }, | 447 { ">", ">" }, |
| 448 { "& &", "& &" }, | 448 { "& &", "& &" }, |
| 449 }; | 449 }; |
| 450 for (size_t i = 0; i < arraysize(tests); ++i) { | 450 for (size_t i = 0; i < arraysize(tests); ++i) { |
| 451 base::string16 result = UnescapeForHTML(base::ASCIIToUTF16(tests[i].input)); | 451 base::string16 result = UnescapeForHTML(base::ASCIIToUTF16(tests[i].input)); |
| 452 EXPECT_EQ(base::ASCIIToUTF16(tests[i].expected_output), result); | 452 EXPECT_EQ(base::ASCIIToUTF16(tests[i].expected_output), result); |
| 453 } | 453 } |
| 454 } | 454 } |
| 455 | 455 |
| 456 TEST(EscapeTest, EscapeExternalHandlerValue) { | |
|
asanka
2014/10/23 07:20:04
Add a test case for invalid percent escape sequenc
asanka
2014/10/23 07:20:04
Have a test case for our identity set:
"!#$&'()*+
Jaekyun Seok (inactive)
2014/10/23 12:43:19
Done.
Jaekyun Seok (inactive)
2014/10/23 12:43:19
Done.
| |
| 457 ASSERT_EQ( | |
| 458 // Escaped | |
| 459 "%02%0A%1D%20!%22#$%25&'()*+,-./0123456789:;" | |
| 460 "%3C=%3E?@ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
| 461 "[%5C]%5E_%60abcdefghijklmnopqrstuvwxyz" | |
| 462 "%7B%7C%7D~%7F%80%FF", | |
| 463 // Most of the character space we care about, un-escaped | |
| 464 EscapeExternalHandlerValue( | |
| 465 "\x02\n\x1d !\"#$%&'()*+,-./0123456789:;" | |
| 466 "<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
| 467 "[\\]^_`abcdefghijklmnopqrstuvwxyz" | |
| 468 "{|}~\x7f\x80\xff")); | |
| 469 | |
| 470 ASSERT_EQ("http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C", | |
| 471 EscapeExternalHandlerValue( | |
| 472 "http://example.com/path/sub?q=a|b|c&q=1|2|3#ref|")); | |
| 473 ASSERT_EQ("http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C", | |
| 474 EscapeExternalHandlerValue( | |
| 475 "http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C")); | |
| 476 ASSERT_EQ("http://[2001:db8:0:1]:80", | |
| 477 EscapeExternalHandlerValue("http://[2001:db8:0:1]:80")); | |
| 478 } | |
| 456 | 479 |
| 457 } // namespace | 480 } // namespace |
| 458 } // namespace net | 481 } // namespace net |
| OLD | NEW |