Title: [93130] trunk/Source/WebCore
Revision
93130
Author
jp...@apple.com
Date
2011-08-16 11:07:20 -0700 (Tue, 16 Aug 2011)

Log Message

New XML parser: Replace assertions regarding character data in the prolog with proper checks
https://bugs.webkit.org/show_bug.cgi?id=66269

Reviewed by Adam Barth.

This patch checks for character data in the prolog (which is illegal in XML) and discards it, instead of failing an assertion.

* xml/parser/XMLTreeBuilder.cpp:
(WebCore::XMLTreeBuilder::processProcessingInstruction):
(WebCore::XMLTreeBuilder::processXMLDeclaration):
(WebCore::XMLTreeBuilder::processDOCTYPE):
(WebCore::XMLTreeBuilder::enterText):
(WebCore::XMLTreeBuilder::failOnText):
* xml/parser/XMLTreeBuilder.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (93129 => 93130)


--- trunk/Source/WebCore/ChangeLog	2011-08-16 18:04:54 UTC (rev 93129)
+++ trunk/Source/WebCore/ChangeLog	2011-08-16 18:07:20 UTC (rev 93130)
@@ -1,3 +1,20 @@
+2011-08-16  Jeffrey Pfau  <jp...@apple.com>
+
+        New XML parser: Replace assertions regarding character data in the prolog with proper checks
+        https://bugs.webkit.org/show_bug.cgi?id=66269
+
+        Reviewed by Adam Barth.
+
+        This patch checks for character data in the prolog (which is illegal in XML) and discards it, instead of failing an assertion.
+
+        * xml/parser/XMLTreeBuilder.cpp:
+        (WebCore::XMLTreeBuilder::processProcessingInstruction):
+        (WebCore::XMLTreeBuilder::processXMLDeclaration):
+        (WebCore::XMLTreeBuilder::processDOCTYPE):
+        (WebCore::XMLTreeBuilder::enterText):
+        (WebCore::XMLTreeBuilder::failOnText):
+        * xml/parser/XMLTreeBuilder.h:
+
 2011-08-16  Alexander Pavlov  <apav...@chromium.org>
 
         Web Inspector: word wrap long edits

Modified: trunk/Source/WebCore/xml/parser/XMLTreeBuilder.cpp (93129 => 93130)


--- trunk/Source/WebCore/xml/parser/XMLTreeBuilder.cpp	2011-08-16 18:04:54 UTC (rev 93129)
+++ trunk/Source/WebCore/xml/parser/XMLTreeBuilder.cpp	2011-08-16 18:07:20 UTC (rev 93130)
@@ -100,7 +100,9 @@
 
 void XMLTreeBuilder::processProcessingInstruction(const AtomicXMLToken& token)
 {
-    ASSERT(!m_leafText);
+    if (!failOnText())
+        return;
+
     // FIXME: fall back if we can't handle the PI ourself.
 
     add(ProcessingInstruction::create(m_document, token.target(), token.data()));
@@ -108,7 +110,8 @@
 
 void XMLTreeBuilder::processXMLDeclaration(const AtomicXMLToken& token)
 {
-    ASSERT(!m_leafText);
+    if (!failOnText())
+        return;
 
     ExceptionCode ec = 0;
 
@@ -134,7 +137,8 @@
     DEFINE_STATIC_LOCAL(AtomicString, xhtmlMathMLSVG, ("-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"));
     DEFINE_STATIC_LOCAL(AtomicString, xhtmlMobile, ("-//WAPFORUM//DTD XHTML Mobile 1.0//EN"));
 
-    ASSERT(!m_leafText);
+    if (!failOnText())
+        return;
 
     AtomicString publicIdentifier(token.publicIdentifier().data(), token.publicIdentifier().size());
     AtomicString systemIdentifier(token.systemIdentifier().data(), token.systemIdentifier().size());
@@ -330,7 +334,7 @@
 void XMLTreeBuilder::enterText()
 {
     if (!m_sawFirstElement) {
-        // FIXME: ensure it's just whitespace
+        // FIXME: Guarantee the text is only whitespace.
         return;
     }
 
@@ -348,6 +352,17 @@
     m_leafText.clear();
 }
 
+bool XMLTreeBuilder::failOnText()
+{
+    if (!m_leafText)
+        return true;
+
+    // FIXME: Guarantee the text is only whitespace.
+
+    m_leafText.clear();
+    return true;
+}
+
 XMLTreeBuilder::NodeStackItem::NodeStackItem(PassRefPtr<ContainerNode> n, NodeStackItem* parent)
     : m_node(n)
 {

Modified: trunk/Source/WebCore/xml/parser/XMLTreeBuilder.h (93129 => 93130)


--- trunk/Source/WebCore/xml/parser/XMLTreeBuilder.h	2011-08-16 18:04:54 UTC (rev 93129)
+++ trunk/Source/WebCore/xml/parser/XMLTreeBuilder.h	2011-08-16 18:07:20 UTC (rev 93130)
@@ -95,6 +95,7 @@
     void appendToText(const UChar* characters, size_t length);
     void enterText();
     void exitText();
+    bool failOnText();
 
     AtomicString namespaceForPrefix(AtomicString prefix, AtomicString fallback);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to