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

Unified Diff: net/base/data_url.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.h ('k') | net/base/data_url_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/data_url.cc
diff --git a/net/base/data_url.cc b/net/base/data_url.cc
index 0ec345ea6dbf4f89ed5701e132109e6c7e411a41..58036c6a369061e6a97c791e728f107da7f8046e 100644
--- a/net/base/data_url.cc
+++ b/net/base/data_url.cc
@@ -66,10 +66,16 @@ bool DataURL::Parse(const GURL& url, std::string* mime_type,
}
if (mime_type->empty()) {
- // fallback to defaults if nothing specified in the URL:
+ // Fallback to the default if nothing specified in the mediatype part as
+ // specified in RFC2045. As specified in RFC2397, we use |charset| even if
+ // |mime_type| is empty.
mime_type->assign("text/plain");
} else if (!ParseMimeTypeWithoutParameter(*mime_type, NULL, NULL)) {
- return false;
+ // Fallback to the default as recommended in RFC2045 when the mediatype
+ // value is invalid. For this case, we don't respect |charset| but force it
+ // set to "US-ASCII".
+ mime_type->assign("text/plain");
+ charset->assign("US-ASCII");
}
if (charset->empty())
charset->assign("US-ASCII");
« no previous file with comments | « net/base/data_url.h ('k') | net/base/data_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698