xref: /php-src/ext/dom/tests/bug69846.phpt (revision 41996e8d)
1--TEST--
2Bug #69846 Segmentation 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 (23) {
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  ["parentElement"]=>
56  NULL
57  ["childNodes"]=>
58  string(22) "(object value omitted)"
59  ["firstChild"]=>
60  NULL
61  ["lastChild"]=>
62  NULL
63  ["previousSibling"]=>
64  NULL
65  ["nextSibling"]=>
66  NULL
67  ["attributes"]=>
68  NULL
69  ["isConnected"]=>
70  bool(false)
71  ["ownerDocument"]=>
72  string(22) "(object value omitted)"
73  ["namespaceURI"]=>
74  NULL
75  ["prefix"]=>
76  string(0) ""
77  ["localName"]=>
78  NULL
79  ["baseURI"]=>
80  NULL
81  ["textContent"]=>
82  string(3) "
83  "
84}
85object(DOMElement)#%d (27) {
86  ["tagName"]=>
87  string(5) "form1"
88  ["className"]=>
89  string(0) ""
90  ["id"]=>
91  string(0) ""
92  ["schemaTypeInfo"]=>
93  NULL
94  ["firstElementChild"]=>
95  string(22) "(object value omitted)"
96  ["lastElementChild"]=>
97  string(22) "(object value omitted)"
98  ["childElementCount"]=>
99  int(3)
100  ["previousElementSibling"]=>
101  NULL
102  ["nextElementSibling"]=>
103  NULL
104  ["nodeName"]=>
105  string(5) "form1"
106  ["nodeValue"]=>
107  string(39) "
108    Value A
109    Value B
110    Value C
111  "
112  ["nodeType"]=>
113  int(1)
114  ["parentNode"]=>
115  NULL
116  ["parentElement"]=>
117  NULL
118  ["childNodes"]=>
119  string(22) "(object value omitted)"
120  ["firstChild"]=>
121  string(22) "(object value omitted)"
122  ["lastChild"]=>
123  string(22) "(object value omitted)"
124  ["previousSibling"]=>
125  NULL
126  ["nextSibling"]=>
127  NULL
128  ["attributes"]=>
129  string(22) "(object value omitted)"
130  ["isConnected"]=>
131  bool(false)
132  ["ownerDocument"]=>
133  string(22) "(object value omitted)"
134  ["namespaceURI"]=>
135  NULL
136  ["prefix"]=>
137  string(0) ""
138  ["localName"]=>
139  string(5) "form1"
140  ["baseURI"]=>
141  NULL
142  ["textContent"]=>
143  string(39) "
144    Value A
145    Value B
146    Value C
147  "
148}
149object(DOMText)#%d (23) {
150  ["wholeText"]=>
151  string(1) "
152"
153  ["data"]=>
154  string(1) "
155"
156  ["length"]=>
157  int(1)
158  ["previousElementSibling"]=>
159  NULL
160  ["nextElementSibling"]=>
161  NULL
162  ["nodeName"]=>
163  string(5) "#text"
164  ["nodeValue"]=>
165  string(1) "
166"
167  ["nodeType"]=>
168  int(3)
169  ["parentNode"]=>
170  NULL
171  ["parentElement"]=>
172  NULL
173  ["childNodes"]=>
174  string(22) "(object value omitted)"
175  ["firstChild"]=>
176  NULL
177  ["lastChild"]=>
178  NULL
179  ["previousSibling"]=>
180  NULL
181  ["nextSibling"]=>
182  NULL
183  ["attributes"]=>
184  NULL
185  ["isConnected"]=>
186  bool(false)
187  ["ownerDocument"]=>
188  string(22) "(object value omitted)"
189  ["namespaceURI"]=>
190  NULL
191  ["prefix"]=>
192  string(0) ""
193  ["localName"]=>
194  NULL
195  ["baseURI"]=>
196  NULL
197  ["textContent"]=>
198  string(1) "
199"
200}
201