php-src/ext/xsl/tests/setParameter_null_bytes.phpt
Niels Dossche 5c749ad4cf Implement request #64137 (XSLTProcessor::setParameter() should allow both quotes to be used)
This reimplements the parameter handling. Instead of quoting the strings
manually, adding them to an array, and passing that as input; use the
libxslt API to pass data verbatim to the processor.
This also simplifies the code a lot.

Closes GH-12331.
2023-09-30 21:41:06 +02:00

43 lines
966 B
PHP

--TEST--
setParameter() with null bytes
--EXTENSIONS--
xsl
--FILE--
<?php
$xslt = new XSLTProcessor();
try {
$xslt->setParameter("", "foo\0", "bar");
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
$xslt->setParameter("", "foo", "bar\0");
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
$xslt->setParameter("", [
"foo\0" => "bar",
]);
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
$xslt->setParameter("", [
"foo" => "bar\0",
]);
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
XSLTProcessor::setParameter(): Argument #2 ($name) must not contain any null bytes
XSLTProcessor::setParameter(): Argument #3 ($value) must not contain any null bytes
XSLTProcessor::setParameter(): Argument #3 ($value) must not contain keys with any null bytes
XSLTProcessor::setParameter(): Argument #3 ($value) must not contain values with any null bytes