Chromium Code Reviews| Index: Source/core/xml/DOMParser.cpp |
| diff --git a/Source/core/xml/DOMParser.cpp b/Source/core/xml/DOMParser.cpp |
| index 25c1cb6d6d222de8bcb4086409d31592094b2c63..da591ae40428df18ca199e29996e98c4d0a21a7f 100644 |
| --- a/Source/core/xml/DOMParser.cpp |
| +++ b/Source/core/xml/DOMParser.cpp |
| @@ -20,14 +20,23 @@ |
| #include "core/xml/DOMParser.h" |
| #include "core/dom/DOMImplementation.h" |
| +#include "core/dom/ExceptionCode.h" |
| #include "wtf/text/WTFString.h" |
| namespace WebCore { |
| -PassRefPtr<Document> DOMParser::parseFromString(const String& str, const String& contentType) |
| +PassRefPtr<Document> DOMParser::parseFromString(const String& str, const String& contentType, ExceptionState& es) |
| { |
| - if (!DOMImplementation::isXMLMIMEType(contentType) && contentType != "text/html") |
| + // HTML5 is very explicit about which types we're allowed to support here: |
| + // http://domparsing.spec.whatwg.org/#the-domparser-interface |
| + if (contentType != "text/html" |
| + && contentType != "text/xml" |
| + && contentType != "application/xml" |
| + && contentType != "application/xhtml+xml" |
| + && contentType != "image/svg+xml") { |
| + es.throwDOMException(TypeError); |
|
eseidel
2013/09/26 20:18:26
I think the name of this function is about to chan
|
| return 0; |
| + } |
| RefPtr<Document> doc = DOMImplementation::createDocument(contentType, 0, KURL(), false); |
| doc->setContent(str); |