1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

libxml_get_external_entity_loader(): test for incompatible resource being loaded (#11728)

A stream resource is expected to be returned by the handler.
This commit is contained in:
George Peter Banyard
2023-07-21 11:56:15 +01:00
committed by GitHub
parent abd563a9d3
commit a17e84f2f7

View File

@@ -0,0 +1,43 @@
--TEST--
libxml_get_external_entity_loader() display correct callable name
--EXTENSIONS--
dom
dba
--FILE--
<?php
$xml = <<<XML
<!DOCTYPE foo PUBLIC "-//FOO/BAR" "http://example.com/foobar">
<foo>bar</foo>
XML;
$dtd = <<<DTD
<!ELEMENT foo (#PCDATA)>
DTD;
class Handler {
public function handle($public, $system, $context) {
$file = __DIR__ . '/db.dba';
return dba_open($file, 'n');
}
}
$o = new Handler();
libxml_set_external_entity_loader([$o, 'handle']);
$dd = new DOMDocument;
$r = $dd->loadXML($xml);
try {
var_dump($dd->validate());
} catch (\Throwable $e) {
var_dump($e->getMessage());
}
?>
--CLEAN--
<?php
$file = __DIR__ . '/db.dba';
unlink($file);
?>
--EXPECT--
string(73) "DOMDocument::validate(): supplied resource is not a valid stream resource"