Skip to content

Commit a702aaa

Browse files
committed
libxml_get_external_entity_loader(): test for incompatible resource being loaded
A stream resource is expected to be returned by the handler.
1 parent 8718fce commit a702aaa

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
libxml_get_external_entity_loader() display correct callable name
3+
--EXTENSIONS--
4+
dom
5+
dba
6+
--FILE--
7+
<?php
8+
9+
$xml = <<<XML
10+
<!DOCTYPE foo PUBLIC "-//FOO/BAR" "http://example.com/foobar">
11+
<foo>bar</foo>
12+
XML;
13+
14+
$dtd = <<<DTD
15+
<!ELEMENT foo (#PCDATA)>
16+
DTD;
17+
18+
class Handler {
19+
public function handle($public, $system, $context) {
20+
$file = __DIR__ . '/db.dba';
21+
return dba_open($file, 'n');
22+
}
23+
}
24+
25+
$o = new Handler();
26+
libxml_set_external_entity_loader([$o, 'handle']);
27+
$dd = new DOMDocument;
28+
$r = $dd->loadXML($xml);
29+
30+
try {
31+
var_dump($dd->validate());
32+
} catch (\Throwable $e) {
33+
var_dump($e->getMessage());
34+
}
35+
36+
?>
37+
--CLEAN--
38+
<?php
39+
$file = __DIR__ . '/db.dba';
40+
unlink($file);
41+
?>
42+
--EXPECT--
43+
string(73) "DOMDocument::validate(): supplied resource is not a valid stream resource"

0 commit comments

Comments
 (0)