Skip to content

Commit bf7372e

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 722b5cc commit bf7372e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
return dba_open('db.dba', 'n');
21+
}
22+
}
23+
24+
$o = new Handler();
25+
libxml_set_external_entity_loader([$o, 'handle']);
26+
$dd = new DOMDocument;
27+
$r = $dd->loadXML($xml);
28+
29+
try {
30+
var_dump($dd->validate());
31+
} catch (\Throwable $e) {
32+
var_dump($e->getMessage());
33+
}
34+
35+
?>
36+
--EXPECT--
37+
string(73) "DOMDocument::validate(): supplied resource is not a valid stream resource"

0 commit comments

Comments
 (0)