1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/dom/tests/modern/common/gh21077.phpt
Niels Dossche d73b2f782e Fix GH-21077: Accessing Dom\Node::baseURI can throw TypeError
Prior to this patch there was a common read handler, and it relied on
the dom class set in the intern document. However, Dom\Implementation
allows creating DTDs unassociated with a document, so we can't rely on
an intern document and the check fails. This causes the ZVAL_NULL() path
to be taken.
To solve this, just split the handler.

Closes GH-21082.
2026-01-30 18:13:55 +01:00

29 lines
577 B
PHP

--TEST--
GH-21077 (Accessing Dom\Node::baseURI can throw TypeError)
--EXTENSIONS--
dom
--CREDITS--
mbeccati
--FILE--
<?php
$implementation = new Dom\Implementation();
$node = $implementation->createDocumentType('html', 'publicId', 'systemId');
var_dump($node->baseURI);
$dom = Dom\XMLDocument::createEmpty();
$dom->append($node = $dom->importNode($node));
var_dump($dom->saveXML());
var_dump($node->baseURI);
?>
--EXPECT--
string(11) "about:blank"
string(84) "<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "publicId" "systemId">
"
string(11) "about:blank"