Reviewed by mjs.
Fix reproducible crash in html parser code.
http://bugzilla.opendarwin.org/show_bug.cgi?id=7137
Test: fast/parser/remove-current-node-parent.html
* html/HTMLParser.cpp:
(WebCore::HTMLParser::handleError):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14048
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-04-25 Eric Seidel <eseidel@apple.com>
+
+ Reviewed by mjs.
+
+ Fix reproducible crasher in HTML parsing code.
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=7137
+
+ * fast/parser/remove-current-node-parent-expected.txt: Added.
+ * fast/parser/remove-current-node-parent.html: Added.
+
2006-04-24 Eric Seidel <eseidel@apple.com>
Reviewed by ggaren.
--- /dev/null
+SUCCESS (no crash!)
--- /dev/null
+<table>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+var x = document.getElementsByTagName('table')[0];
+x.parentNode.removeChild(x);
+</script>
+<span>At the time of writing, our current behavior ignores content in subtrees removed during parsing.
+ However, HTML5 suggests it should not be ignored.
+ See: http://www.hixie.ch/tests/adhoc/html/parsing/error-handling/034.html
+ and: http://bugzilla.opendarwin.org/show_bug.cgi?id=7137</span>
+</table><span>SUCCESS (no crash!)</span>
+2006-04-25 Eric Seidel <eseidel@apple.com>
+
+ Reviewed by mjs.
+
+ Fix reproducible crash in html parser code.
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=7137
+
+ Test: fast/parser/remove-current-node-parent.html
+
+ * html/HTMLParser.cpp:
+ (WebCore::HTMLParser::handleError):
+
2006-04-25 Maciej Stachowiak <mjs@apple.com>
Reviewed by Eric.
if (possiblyMoveStrayContent) {
Node *node = current;
Node *parent = node->parentNode();
+ // It is allowed for nodes on the node stack to have been removed from the tree, thus we have to check (parentNode() == NULL) first
+ // http://bugzilla.opendarwin.org/show_bug.cgi?id=7137
+ if (!parent)
+ return false;
Node *grandparent = parent->parentNode();
+ if (!grandparent)
+ return false;
if (n->isTextNode() ||
(h->hasLocalName(trTag) &&
node = (node->hasTagName(tableTag)) ? node :
((node->hasTagName(trTag)) ? grandparent : parent);
Node *parent = node->parentNode();
+ if (!parent)
+ return false;
parent->insertBefore(n, node, ec);
if (!ec) {
if (n->isHTMLElement() && tagPriority > 0 &&