php-src/ext/dom/tests/php_function_edge_cases.phpt
Niels Dossche 20c9c4a367 Fix validation logic of php:function() callbacks in dom and xsl
Two issues:
- Assumed that at least 1 argument (function name) was provided.
- Incorrect error path for the non-callable case.

Closes GH-12593.
2023-11-02 20:28:55 +01:00

27 lines
583 B
PHP

--TEST--
php:function() edge cases
--EXTENSIONS--
dom
--FILE--
<?php
$doc = new DOMDocument();
$doc->loadHTML('<a href="https://php.net">hello</a>');
$xpath = new DOMXpath($doc);
$xpath->registerNamespace("php", "http://php.net/xpath");
$xpath->registerPHPFunctions();
try {
$xpath->query("//a[php:function(3)]");
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$xpath->query("//a[php:function()]");
} catch (Throwable $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Handler name must be a string
Function name must be passed as the first argument