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

Unified Diff: net/base/data_url_unittest.cc

Issue 643963004: Unescape BiDi control chars while parsing data urls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a browsertest 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
Index: net/base/data_url_unittest.cc
diff --git a/net/base/data_url_unittest.cc b/net/base/data_url_unittest.cc
index 3876301cad5ecb441630d1669bbbc8a6fcac8118..2ea7cb3fb5ede283fc57cd7e8b5fba3dfd4609d3 100644
--- a/net/base/data_url_unittest.cc
+++ b/net/base/data_url_unittest.cc
@@ -184,6 +184,42 @@ TEST(DataURLTest, Parse) {
"",
"" },
+ // BiDi control characters should be unescaped and preserved as is, and
+ // should not be replaced with % versions. In the below case, \xE2\x80\x8F
+ // is the RTL mark and the parsed text should preserve it as is.
+ {
+ "data:text/html;charset=utf-8,<b>\xE2\x80\x8Ftest</b>",
mmenke 2014/10/17 15:24:43 Any reason not to just use text/plain? Don't thin
meacer 2014/10/17 20:41:54 Done.
+ true,
+ "text/html",
+ "utf-8",
+ "<b>\xE2\x80\x8Ftest</b>"},
+
+ // Same as above but with Arabic text after RTL mark.
+ {
+ "data:text/html;charset=utf-8,"
+ "<b>\xE2\x80\x8F\xD8\xA7\xD8\xAE\xD8\xAA\xD8\xA8\xD8\xA7\xD8\xB1</b>",
+ true,
+ "text/html",
+ "utf-8",
+ "<b>\xE2\x80\x8F\xD8\xA7\xD8\xAE\xD8\xAA\xD8\xA8\xD8\xA7\xD8\xB1</b>"},
+
+ // RTL mark encoded as %E2%80%8F should be unescaped too.
+ {
+ "data:text/html;charset=utf-8,<b>%E2%80%8Ftest</b>",
mmenke 2014/10/17 15:24:44 When this is wrapped in a GURL, this becomes the s
meacer 2014/10/17 20:41:54 Added a note.
+ true,
+ "text/html",
+ "utf-8",
+ "<b>\xE2\x80\x8Ftest</b>"},
+
+ // Same as above but with Arabic text after RTL mark.
+ {
+ "data:text/html;charset=utf-8,"
+ "<b>%E2%80%8F\xD8\xA7\xD8\xAE\xD8\xAA\xD8\xA8\xD8\xA7\xD8\xB1</b>",
+ true,
+ "text/html",
+ "utf-8",
+ "<b>\xE2\x80\x8F\xD8\xA7\xD8\xAE\xD8\xAA\xD8\xA8\xD8\xA7\xD8\xB1</b>"}
+
// TODO(darin): add more interesting tests
};

Powered by Google App Engine
This is Rietveld 408576698