rrichards Wed Nov 28 10:43:02 2007 UTC Added files: /php-src/ext/dom/tests bug43364.phpt
Modified files: /php-src/ext/dom document.c Log: Fix bug #43364 (recursive xincludes don't remove internal nodes properly) http://cvs.php.net/viewvc.cgi/php-src/ext/dom/document.c?r1=1.88&r2=1.89&diff_format=u Index: php-src/ext/dom/document.c diff -u php-src/ext/dom/document.c:1.88 php-src/ext/dom/document.c:1.89 --- php-src/ext/dom/document.c:1.88 Sun Oct 7 05:15:03 2007 +++ php-src/ext/dom/document.c Wed Nov 28 10:43:01 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: document.c,v 1.88 2007/10/07 05:15:03 davidw Exp $ */ +/* $Id: document.c,v 1.89 2007/11/28 10:43:01 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1767,6 +1767,10 @@ /* 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; } http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/bug43364.phpt?view=markup&rev=1.1 Index: php-src/ext/dom/tests/bug43364.phpt +++ php-src/ext/dom/tests/bug43364.phpt --TEST-- Bug #43364 (recursive xincludes don't remove internal xml nodes properly) --FILE-- <?php function loopElements($nodes) { $count = 0; foreach($nodes as $node) { if($node instanceof DOMElement) { $count++; if($node->childNodes->length > 0) { $count += loopElements($node->childNodes); } } } return $count; } $xml = <<<DOC <?xml version="1.0" encoding="UTF-8"?> <root xmlns:xi="http://www.w3.org/2001/XInclude"> <a> <a_child1>ac1</a_child1> <a_child2>ac2</a_child2> </a> <b><xi:include xpointer="xpointer(/root/a)" /></b> <c><xi:include xpointer="xpointer(/root/b)" /></c> </root> DOC; $doc = new DomDocument(); $doc->loadXml($xml); $doc->xinclude(); $count = loopElements(array($doc->documentElement)); var_dump($count); ?> --EXPECT-- int(13) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php