Skip to content

ext/libxml: Add test to attempt to trigger a specific code path #11728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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"