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

Unified Diff: third_party/WebKit/Source/core/fetch/DocumentResource.cpp

Issue 1706243002: Don't use SVG resource documents with an unrecognized MIME-type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use testharness; add unit test for extractMIMETypeFromMediaType Created 4 years, 10 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/fetch/DocumentResource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/DocumentResource.cpp b/third_party/WebKit/Source/core/fetch/DocumentResource.cpp
index aab75f75f9c939b780a973889aa8041dcfd10c7e..d076e1ad6b38d9a33360100f2e9760fb45edfc03 100644
--- a/third_party/WebKit/Source/core/fetch/DocumentResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/DocumentResource.cpp
@@ -67,7 +67,7 @@ String DocumentResource::encoding() const
void DocumentResource::checkNotify()
{
- if (m_data) {
+ if (m_data && mimeTypeAllowed()) {
StringBuilder decodedText;
decodedText.append(m_decoder->decode(m_data->data(), m_data->size()));
decodedText.append(m_decoder->flush());
@@ -78,6 +78,18 @@ void DocumentResource::checkNotify()
Resource::checkNotify();
}
+bool DocumentResource::mimeTypeAllowed() const
+{
+ ASSERT(type() == SVGDocument);
+ AtomicString mimeType = response().mimeType();
+ if (response().isHTTP())
+ mimeType = httpContentType();
+ return mimeType == "image/svg+xml"
+ || mimeType == "text/xml"
+ || mimeType == "application/xml"
+ || mimeType == "application/xhtml+xml";
+}
+
PassRefPtrWillBeRawPtr<Document> DocumentResource::createDocument(const KURL& url)
{
switch (type()) {
« no previous file with comments | « third_party/WebKit/Source/core/fetch/DocumentResource.h ('k') | third_party/WebKit/Source/core/fetch/Resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698