File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -1767,6 +1767,10 @@ static void php_dom_remove_xinclude_nodes(xmlNodePtr cur TSRMLS_DC) {
1767
1767
1768
1768
/* XML_XINCLUDE_END node will be a sibling of XML_XINCLUDE_START */
1769
1769
while (cur && cur -> type != XML_XINCLUDE_END ) {
1770
+ /* remove xinclude processing nodes from recursive xincludes */
1771
+ if (cur -> type == XML_ELEMENT_NODE ) {
1772
+ php_dom_remove_xinclude_nodes (cur -> children TSRMLS_CC );
1773
+ }
1770
1774
cur = cur -> next ;
1771
1775
}
1772
1776
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #43364 (recursive xincludes don't remove internal xml nodes properly)
3
+ --FILE--
4
+ <?php
5
+ function loopElements ($ nodes )
6
+ {
7
+ $ count = 0 ;
8
+ foreach ($ nodes as $ node ) {
9
+ if ($ node instanceof DOMElement) {
10
+ $ count ++;
11
+ if ($ node ->childNodes ->length > 0 ) {
12
+ $ count += loopElements ($ node ->childNodes );
13
+ }
14
+ }
15
+ }
16
+ return $ count ;
17
+ }
18
+
19
+ $ xml = <<<DOC
20
+ <?xml version="1.0" encoding="UTF-8"?>
21
+ <root xmlns:xi="http://www.w3.org/2001/XInclude">
22
+ <a>
23
+ <a_child1>ac1</a_child1>
24
+ <a_child2>ac2</a_child2>
25
+ </a>
26
+ <b><xi:include xpointer="xpointer(/root/a)" /></b>
27
+ <c><xi:include xpointer="xpointer(/root/b)" /></c>
28
+ </root>
29
+ DOC ;
30
+
31
+ $ doc = new DomDocument ();
32
+ $ doc ->loadXml ($ xml );
33
+ $ doc ->xinclude ();
34
+
35
+ $ count = loopElements (array ($ doc ->documentElement ));
36
+
37
+ var_dump ($ count );
38
+ ?>
39
+ --EXPECT--
40
+ int(13)
You can’t perform that action at this time.
0 commit comments