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

Unified Diff: third_party/WebKit/Source/core/dom/ScriptLoader.cpp

Issue 2294283002: Stop sniffing 'audio/', 'video/', and 'text/csv' into script. (Closed)
Patch Set: rebase Created 4 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
Index: third_party/WebKit/Source/core/dom/ScriptLoader.cpp
diff --git a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
index ed5c0f3b2cb0978ec4f3a670470b771a4cfc23eb..ffebfa4db4587c37ef4d17ee35fcf30536cdca9c 100644
--- a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
+++ b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
@@ -388,9 +388,16 @@ bool ScriptLoader::executeScript(const ScriptSourceCode& sourceCode)
}
String mimetype = resource->httpContentType();
- if (mimetype.startsWith("image/")) {
+ if (mimetype.startsWith("image/") || mimetype == "text/csv" || mimetype.startsWith("audio/") || mimetype.startsWith("video/")) {
contextDocument->addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, ErrorMessageLevel, "Refused to execute script from '" + resource->url().elidedString() + "' because its MIME type ('" + mimetype + "') is not executable."));
- UseCounter::count(frame, UseCounter::BlockedSniffingImageToScript);
+ if (mimetype.startsWith("image/"))
+ UseCounter::count(frame, UseCounter::BlockedSniffingImageToScript);
+ else if (mimetype.startsWith("audio/"))
+ UseCounter::count(frame, UseCounter::BlockedSniffingAudioToScript);
+ else if (mimetype.startsWith("video/"))
+ UseCounter::count(frame, UseCounter::BlockedSniffingVideoToScript);
+ else if (mimetype == "text/csv")
+ UseCounter::count(frame, UseCounter::BlockedSniffingCSVToScript);
return false;
}

Powered by Google App Engine
This is Rietveld 408576698