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

Unified Diff: Source/core/inspector/DOMPatchSupport.cpp

Issue 729453003: DevTools: Fix crash when setting invalid outer XML for an XML document (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revert to ASSERT, detach parser() after finish() Created 6 years, 1 month 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 | « LayoutTests/inspector/elements/set-outer-html-for-xhtml-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/DOMPatchSupport.cpp
diff --git a/Source/core/inspector/DOMPatchSupport.cpp b/Source/core/inspector/DOMPatchSupport.cpp
index 9708d9671ef630af589c9776f11745de8b1ea04c..9ff59837de960c62edf96cd6a3481e017e9ee9e2 100644
--- a/Source/core/inspector/DOMPatchSupport.cpp
+++ b/Source/core/inspector/DOMPatchSupport.cpp
@@ -85,6 +85,8 @@ void DOMPatchSupport::patchDocument(const String& markup)
RefPtrWillBeRawPtr<Document> newDocument = nullptr;
if (document().isHTMLDocument())
newDocument = HTMLDocument::create();
+ else if (document().isSVGDocument())
+ newDocument = XMLDocument::createSVG();
else if (document().isXHTMLDocument())
newDocument = XMLDocument::createXHTML();
else if (document().isXMLDocument())
@@ -92,16 +94,18 @@ void DOMPatchSupport::patchDocument(const String& markup)
ASSERT(newDocument);
newDocument->setContextFeatures(document().contextFeatures());
aandrey 2014/11/17 15:47:53 if a new document type will be added, it will cras
apavlov 2014/11/17 16:04:39 That's what ASSERT() is for.
apavlov 2014/11/17 16:05:55 Eh, I see what you mean. I cannot think of a way t
- RefPtrWillBeRawPtr<DocumentParser> parser = nullptr;
- if (document().isHTMLDocument())
- parser = HTMLDocumentParser::create(toHTMLDocument(*newDocument), false);
- else
- parser = XMLDocumentParser::create(*newDocument, 0);
- parser->pinToMainThread();
- parser->insert(markup); // Use insert() so that the parser will not yield.
- parser->finish();
- parser->detach();
-
+ if (!document().isHTMLDocument()) {
+ RefPtrWillBeRawPtr<DocumentParser> parser = XMLDocumentParser::create(*newDocument, nullptr);
+ parser->pinToMainThread();
+ parser->append(markup.impl());
+ parser->finish();
+ parser->detach();
+
+ // Avoid breakage on non-well-formed documents.
+ if (!static_cast<XMLDocumentParser*>(parser.get())->wellFormed())
aandrey 2014/11/17 15:47:53 you can remove this static_cast with proper type f
apavlov 2014/11/17 16:04:39 With a proper type for parser, I cannot call appen
+ return;
+ }
+ newDocument->setContent(markup);
OwnPtr<Digest> oldInfo = createDigest(document().documentElement(), 0);
OwnPtr<Digest> newInfo = createDigest(newDocument->documentElement(), &m_unusedNodesMap);
« no previous file with comments | « LayoutTests/inspector/elements/set-outer-html-for-xhtml-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698