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

Unified Diff: Source/core/xml/DOMParser.cpp

Issue 24483007: Make DOMParser::parseFromString specification compliant and throw exception in error scenario. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch after adding descriptive message. Created 7 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 | « Source/core/xml/DOMParser.h ('k') | Source/core/xml/DOMParser.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/xml/DOMParser.cpp
diff --git a/Source/core/xml/DOMParser.cpp b/Source/core/xml/DOMParser.cpp
index 25c1cb6d6d222de8bcb4086409d31592094b2c63..29a37da443b3d171f6b20c38ceecac077c9f6e62 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, "Unsupported mime-type specified.");
return 0;
+ }
RefPtr<Document> doc = DOMImplementation::createDocument(contentType, 0, KURL(), false);
doc->setContent(str);
« no previous file with comments | « Source/core/xml/DOMParser.h ('k') | Source/core/xml/DOMParser.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698