File: gh19098.phpt

package info (click to toggle)
php8.4 8.4.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 211,276 kB
  • sloc: ansic: 1,176,142; php: 35,419; sh: 11,964; cpp: 7,208; pascal: 4,951; javascript: 3,091; asm: 2,817; yacc: 2,411; makefile: 696; xml: 446; python: 301; awk: 148
file content (44 lines) | stat: -rw-r--r-- 1,241 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
--TEST--
GH-19098 (libxml<2.13 segmentation fault caused by php_libxml_node_free)
--EXTENSIONS--
xmlreader
dom
--FILE--
<?php

$xml_reader = \XMLReader::XML('
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
 <results>
  <result><binding xml:id="foo" xmlns:custom="urn:custom" custom:foo="bar" name="s"><uri/></binding></result>
 </results>
</sparql>');

$success = $xml_reader->next("sparql");

$success = $xml_reader->read();
$success = $xml_reader->next("results");

while ($xml_reader->read()) {
  if ($xml_reader->next("result")) {
    $result_as_dom_node = $xml_reader->expand();
    $child = $result_as_dom_node->firstChild;
    unset($result_as_dom_node);
    var_dump($child->namespaceURI);
    foreach ($child->attributes as $attr) {
      var_dump($attr->namespaceURI);
    }
    $doc = new DOMDocument;
    $doc->adoptNode($child);
    echo $doc->saveXML($child), "\n";
    unset($child);
    break;
  }
}

?>
--EXPECT--
string(38) "http://www.w3.org/2005/sparql-results#"
string(36) "http://www.w3.org/XML/1998/namespace"
string(10) "urn:custom"
NULL
<default:binding xmlns:custom="urn:custom" xmlns:default="http://www.w3.org/2005/sparql-results#" xml:id="foo" custom:foo="bar" name="s"><default:uri/></default:binding>