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

Unified 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 side-by-side diff with in-line comments
Download patch
« net/base/escape.h ('K') | « net/base/escape.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/escape_unittest.cc
diff --git a/net/base/escape_unittest.cc b/net/base/escape_unittest.cc
index 74ae29336d82c2f1ea1379edb196a9b8392b0a1b..4891b08f95a5bc9aff54937ac345572a8f6a9745 100644
--- a/net/base/escape_unittest.cc
+++ b/net/base/escape_unittest.cc
@@ -453,6 +453,24 @@ TEST(EscapeTest, UnescapeForHTML) {
}
}
+TEST(EscapeTest, EscapeQueryPart) {
+ ASSERT_EQ(
+ // Escaped
+ "%02%0A%1D%20!%22%23$%25&'()*+,-./0123456789:;"
+ "%3C=%3E?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz"
+ "%7B%7C%7D~%7F%80%FF",
+ // Most of the character space we care about, un-escaped
+ EscapeQueryPart(
+ "\x02\n\x1d !\"#$%&'()*+,-./0123456789:;"
+ "<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "[\\]^_`abcdefghijklmnopqrstuvwxyz"
+ "{|}~\x7f\x80\xff"));
+ ASSERT_EQ("q=a%7Cb%7Cc", EscapeQueryPart("q=a%7Cb%7Cc"));
+ ASSERT_EQ("q=a%7Cb%7Cc", EscapeQueryPart("q=a|b|c"));
+ ASSERT_EQ("q=a%7Cb%7Cc&q2=1%7C2%7C3", EscapeQueryPart("q=a|b|c&q2=1|2|3"));
+}
+
} // namespace
} // namespace net
« 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