xref: /PHP-8.4/ext/dom/tests/gh17224.phpt (revision d2b6b646)
1--TEST--
2GH-17224 (UAF in importNode)
3--EXTENSIONS--
4dom
5--CREDITS--
6YuanchengJiang
7--FILE--
8<?php
9$aDOM = new DOMDocument();
10$fromdom = new DOMDocument();
11$fromdom->loadXML('<data xmlns:ai="http://test.org" ai:attr="namespaced" />');
12$attr = $fromdom->firstChild->attributes->item(0);
13$att = $aDOM->importNode($attr);
14$doc = new DOMDocument;
15$fromdom->load(__DIR__."/book.xml");
16unset($attr);
17var_dump($att);
18?>
19--EXPECTF--
20object(DOMAttr)#%d (%d) {
21  ["name"]=>
22  string(4) "attr"
23  ["specified"]=>
24  bool(true)
25  ["value"]=>
26  string(10) "namespaced"
27  ["ownerElement"]=>
28  NULL
29  ["schemaTypeInfo"]=>
30  NULL
31  ["nodeName"]=>
32  string(7) "ai:attr"
33  ["nodeValue"]=>
34  string(10) "namespaced"
35  ["nodeType"]=>
36  int(2)
37  ["parentNode"]=>
38  NULL
39  ["parentElement"]=>
40  NULL
41  ["childNodes"]=>
42  string(22) "(object value omitted)"
43  ["firstChild"]=>
44  string(22) "(object value omitted)"
45  ["lastChild"]=>
46  string(22) "(object value omitted)"
47  ["previousSibling"]=>
48  NULL
49  ["nextSibling"]=>
50  NULL
51  ["attributes"]=>
52  NULL
53  ["isConnected"]=>
54  bool(false)
55  ["ownerDocument"]=>
56  string(22) "(object value omitted)"
57  ["namespaceURI"]=>
58  string(15) "http://test.org"
59  ["prefix"]=>
60  string(2) "ai"
61  ["localName"]=>
62  string(4) "attr"
63  ["baseURI"]=>
64  NULL
65  ["textContent"]=>
66  string(10) "namespaced"
67}
68