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

Unified Diff: net/base/data_url_unittest.cc

Issue 555383003: [Regression fix] [Data URI parser] Accept data URI with invalid mediatype data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit tests Created 6 years, 3 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
« no previous file with comments | « net/base/data_url.cc ('k') | net/url_request/url_request_data_job_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/data_url_unittest.cc
diff --git a/net/base/data_url_unittest.cc b/net/base/data_url_unittest.cc
index 5a5dbe8f008d98c460a48e7f504ffbaebac3c630..3876301cad5ecb441630d1669bbbc8a6fcac8118 100644
--- a/net/base/data_url_unittest.cc
+++ b/net/base/data_url_unittest.cc
@@ -63,6 +63,28 @@ TEST(DataURLTest, Parse) {
"US-ASCII",
"hello world" },
+ // Allow invalid mediatype for backward compatibility but set mime_type to
+ // "text/plain" instead of the invalid mediatype.
+ { "data:foo,boo",
+ true,
+ "text/plain",
+ "US-ASCII",
+ "boo" },
+
+ // When accepting an invalid mediatype, override charset with "US-ASCII"
+ { "data:foo;charset=UTF-8,boo",
+ true,
+ "text/plain",
+ "US-ASCII",
+ "boo" },
+
+ // Invalid mediatype. Includes a slash but the type part is not a token.
+ { "data:f(oo/bar;baz=1;charset=kk,boo",
+ true,
+ "text/plain",
+ "US-ASCII",
+ "boo" },
+
{ "data:foo/bar;baz=1;charset=kk,boo",
true,
"foo/bar",
@@ -88,13 +110,6 @@ TEST(DataURLTest, Parse) {
"US-ASCII",
"<html><body><b>hello world</b></body></html>" },
- // Bad mime type
- { "data:f(oo/bar;baz=1;charset=kk,boo",
- false,
- "",
- "",
- "" },
-
// the comma cannot be url-escaped!
{ "data:%2Cblah",
false,
« no previous file with comments | « net/base/data_url.cc ('k') | net/url_request/url_request_data_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698