xref: /PHP-8.1/ext/dom/tests/bug69846.phpt (revision 7da2151f)
1--TEST--
2Bug #69846 Segmenation fault (access violation) when iterating over DOMNodeList
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$tmpDomDocument = new DOMDocument();
9
10$xml = '<?xml version="1.0" encoding="UTF-8"?><dummy xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><xfa:data>
11  <form1>
12    <TextField1>Value A</TextField1>
13    <TextField1>Value B</TextField1>
14    <TextField1>Value C</TextField1>
15  </form1>
16</xfa:data></dummy>';
17
18$tmpDomDocument->loadXML($xml);
19
20$dataNodes = $tmpDomDocument->firstChild->childNodes->item(0)->childNodes;
21
22var_dump($dataNodes->length);
23$datasetDom = new DOMDocument();
24
25foreach ($dataNodes AS $node) {
26    $node = $datasetDom->importNode($node, true);
27    var_dump($node);
28}
29
30?>
31--EXPECTF--
32int(3)
33object(DOMText)#%d (21) {
34  ["wholeText"]=>
35  string(3) "
36  "
37  ["data"]=>
38  string(3) "
39  "
40  ["length"]=>
41  int(3)
42  ["previousElementSibling"]=>
43  NULL
44  ["nextElementSibling"]=>
45  NULL
46  ["nodeName"]=>
47  string(5) "#text"
48  ["nodeValue"]=>
49  string(3) "
50  "
51  ["nodeType"]=>
52  int(3)
53  ["parentNode"]=>
54  NULL
55  ["childNodes"]=>
56  string(22) "(object value omitted)"
57  ["firstChild"]=>
58  NULL
59  ["lastChild"]=>
60  NULL
61  ["previousSibling"]=>
62  NULL
63  ["nextSibling"]=>
64  NULL
65  ["attributes"]=>
66  NULL
67  ["ownerDocument"]=>
68  string(22) "(object value omitted)"
69  ["namespaceURI"]=>
70  NULL
71  ["prefix"]=>
72  string(0) ""
73  ["localName"]=>
74  NULL
75  ["baseURI"]=>
76  NULL
77  ["textContent"]=>
78  string(3) "
79  "
80}
81object(DOMElement)#7 (23) {
82  ["schemaTypeInfo"]=>
83  NULL
84  ["tagName"]=>
85  string(5) "form1"
86  ["firstElementChild"]=>
87  string(22) "(object value omitted)"
88  ["lastElementChild"]=>
89  string(22) "(object value omitted)"
90  ["childElementCount"]=>
91  int(3)
92  ["previousElementSibling"]=>
93  NULL
94  ["nextElementSibling"]=>
95  NULL
96  ["nodeName"]=>
97  string(5) "form1"
98  ["nodeValue"]=>
99  string(39) "
100    Value A
101    Value B
102    Value C
103  "
104  ["nodeType"]=>
105  int(1)
106  ["parentNode"]=>
107  NULL
108  ["childNodes"]=>
109  string(22) "(object value omitted)"
110  ["firstChild"]=>
111  string(22) "(object value omitted)"
112  ["lastChild"]=>
113  string(22) "(object value omitted)"
114  ["previousSibling"]=>
115  NULL
116  ["nextSibling"]=>
117  NULL
118  ["attributes"]=>
119  string(22) "(object value omitted)"
120  ["ownerDocument"]=>
121  string(22) "(object value omitted)"
122  ["namespaceURI"]=>
123  NULL
124  ["prefix"]=>
125  string(0) ""
126  ["localName"]=>
127  string(5) "form1"
128  ["baseURI"]=>
129  NULL
130  ["textContent"]=>
131  string(39) "
132    Value A
133    Value B
134    Value C
135  "
136}
137object(DOMText)#%d (21) {
138  ["wholeText"]=>
139  string(1) "
140"
141  ["data"]=>
142  string(1) "
143"
144  ["length"]=>
145  int(1)
146  ["previousElementSibling"]=>
147  NULL
148  ["nextElementSibling"]=>
149  NULL
150  ["nodeName"]=>
151  string(5) "#text"
152  ["nodeValue"]=>
153  string(1) "
154"
155  ["nodeType"]=>
156  int(3)
157  ["parentNode"]=>
158  NULL
159  ["childNodes"]=>
160  string(22) "(object value omitted)"
161  ["firstChild"]=>
162  NULL
163  ["lastChild"]=>
164  NULL
165  ["previousSibling"]=>
166  NULL
167  ["nextSibling"]=>
168  NULL
169  ["attributes"]=>
170  NULL
171  ["ownerDocument"]=>
172  string(22) "(object value omitted)"
173  ["namespaceURI"]=>
174  NULL
175  ["prefix"]=>
176  string(0) ""
177  ["localName"]=>
178  NULL
179  ["baseURI"]=>
180  NULL
181  ["textContent"]=>
182  string(1) "
183"
184}
185