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

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

Issue 632843003: Add a function to escape a query part of url (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Follow RFC 2396 to escape a query part of url 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
« net/base/escape.h ('K') | « 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) 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
446 { "&lt;", "<" }, 446 { "&lt;", "<" },
447 { "&gt;", ">" }, 447 { "&gt;", ">" },
448 { "&amp; &", "& &" }, 448 { "&amp; &", "& &" },
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, EscapeQueryPart) {
457 ASSERT_EQ(
458 // Escaped
459 "%02%0A%1D%20!%22%23$%25&'()*+,-./0123456789:;"
460 "%3C=%3E?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
461 "%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz"
462 "%7B%7C%7D~%7F%80%FF",
463 // Most of the character space we care about, un-escaped
464 EscapeQueryPart(
465 "\x02\n\x1d !\"#$%&'()*+,-./0123456789:;"
466 "<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
467 "[\\]^_`abcdefghijklmnopqrstuvwxyz"
468 "{|}~\x7f\x80\xff"));
469 ASSERT_EQ("q=a%7Cb%7Cc", EscapeQueryPart("q=a%7Cb%7Cc"));
470 ASSERT_EQ("q=a%7Cb%7Cc", EscapeQueryPart("q=a|b|c"));
471 ASSERT_EQ("q=a%7Cb%7Cc&q2=1%7C2%7C3", EscapeQueryPart("q=a|b|c&q2=1|2|3"));
472 }
473
456 474
457 } // namespace 475 } // namespace
458 } // namespace net 476 } // namespace net
OLDNEW
« net/base/escape.h ('K') | « net/base/escape.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698