xref: /PHP-7.4/ext/dom/tests/bug69846.phpt (revision 09669411)
1--TEST--
2Bug #69846 Segmenation fault (access violation) when iterating over DOMNodeList
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
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===DONE===
32--EXPECTF--
33int(3)
34object(DOMText)#%d (19) {
35  ["wholeText"]=>
36  string(3) "
37  "
38  ["data"]=>
39  string(3) "
40  "
41  ["length"]=>
42  int(3)
43  ["nodeName"]=>
44  string(5) "#text"
45  ["nodeValue"]=>
46  string(3) "
47  "
48  ["nodeType"]=>
49  int(3)
50  ["parentNode"]=>
51  NULL
52  ["childNodes"]=>
53  string(22) "(object value omitted)"
54  ["firstChild"]=>
55  NULL
56  ["lastChild"]=>
57  NULL
58  ["previousSibling"]=>
59  NULL
60  ["nextSibling"]=>
61  NULL
62  ["attributes"]=>
63  NULL
64  ["ownerDocument"]=>
65  string(22) "(object value omitted)"
66  ["namespaceURI"]=>
67  NULL
68  ["prefix"]=>
69  string(0) ""
70  ["localName"]=>
71  NULL
72  ["baseURI"]=>
73  NULL
74  ["textContent"]=>
75  string(3) "
76  "
77}
78object(DOMElement)#%d (18) {
79  ["tagName"]=>
80  string(5) "form1"
81  ["schemaTypeInfo"]=>
82  NULL
83  ["nodeName"]=>
84  string(5) "form1"
85  ["nodeValue"]=>
86  string(39) "
87    Value A
88    Value B
89    Value C
90  "
91  ["nodeType"]=>
92  int(1)
93  ["parentNode"]=>
94  NULL
95  ["childNodes"]=>
96  string(22) "(object value omitted)"
97  ["firstChild"]=>
98  string(22) "(object value omitted)"
99  ["lastChild"]=>
100  string(22) "(object value omitted)"
101  ["previousSibling"]=>
102  NULL
103  ["nextSibling"]=>
104  NULL
105  ["attributes"]=>
106  string(22) "(object value omitted)"
107  ["ownerDocument"]=>
108  string(22) "(object value omitted)"
109  ["namespaceURI"]=>
110  NULL
111  ["prefix"]=>
112  string(0) ""
113  ["localName"]=>
114  string(5) "form1"
115  ["baseURI"]=>
116  NULL
117  ["textContent"]=>
118  string(39) "
119    Value A
120    Value B
121    Value C
122  "
123}
124object(DOMText)#%d (19) {
125  ["wholeText"]=>
126  string(1) "
127"
128  ["data"]=>
129  string(1) "
130"
131  ["length"]=>
132  int(1)
133  ["nodeName"]=>
134  string(5) "#text"
135  ["nodeValue"]=>
136  string(1) "
137"
138  ["nodeType"]=>
139  int(3)
140  ["parentNode"]=>
141  NULL
142  ["childNodes"]=>
143  string(22) "(object value omitted)"
144  ["firstChild"]=>
145  NULL
146  ["lastChild"]=>
147  NULL
148  ["previousSibling"]=>
149  NULL
150  ["nextSibling"]=>
151  NULL
152  ["attributes"]=>
153  NULL
154  ["ownerDocument"]=>
155  string(22) "(object value omitted)"
156  ["namespaceURI"]=>
157  NULL
158  ["prefix"]=>
159  string(0) ""
160  ["localName"]=>
161  NULL
162  ["baseURI"]=>
163  NULL
164  ["textContent"]=>
165  string(1) "
166"
167}
168===DONE===
169