From: Rob Richards Date: Wed, 28 Nov 2007 10:44:21 +0000 (+0000) Subject: MFH: Fix bug #43364 (recursive xincludes don't remove internal nodes properly) X-Git-Tag: RELEASE_1_3_1~564 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4cd1b9d8032c455ceb2ebc7177a5cf785811acc5;p=php MFH: Fix bug #43364 (recursive xincludes don't remove internal nodes properly) add test --- diff --git a/ext/dom/document.c b/ext/dom/document.c index acfcc71f1d..490e56e359 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1737,6 +1737,10 @@ static void php_dom_remove_xinclude_nodes(xmlNodePtr cur TSRMLS_DC) { /* XML_XINCLUDE_END node will be a sibling of XML_XINCLUDE_START */ while(cur && cur->type != XML_XINCLUDE_END) { + /* remove xinclude processing nodes from recursive xincludes */ + if (cur->type == XML_ELEMENT_NODE) { + php_dom_remove_xinclude_nodes(cur->children TSRMLS_CC); + } cur = cur->next; } diff --git a/ext/dom/tests/bug43364.phpt b/ext/dom/tests/bug43364.phpt new file mode 100644 index 0000000000..0df581b7ac --- /dev/null +++ b/ext/dom/tests/bug43364.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #43364 (recursive xincludes don't remove internal xml nodes properly) +--FILE-- +childNodes->length > 0) { + $count += loopElements($node->childNodes); + } + } + } + return $count; +} + +$xml = << + + + ac1 + ac2 + + + + +DOC; + +$doc = new DomDocument(); +$doc->loadXml($xml); +$doc->xinclude(); + +$count = loopElements(array($doc->documentElement)); + +var_dump($count); +?> +--EXPECT-- +int(13)