From d6be34b1e89e7a2d58d52ecf19d6f0dcf5387b73 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:18:08 +0200 Subject: [PATCH] Add test for performing special operations on XSLTProcessor properties This covers some uncovered code paths in custom property handling in php_xsl.c --- .../special_operations_with_properties.phpt | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 ext/xsl/tests/special_operations_with_properties.phpt diff --git a/ext/xsl/tests/special_operations_with_properties.phpt b/ext/xsl/tests/special_operations_with_properties.phpt new file mode 100644 index 0000000000000..b7904fad8d866 --- /dev/null +++ b/ext/xsl/tests/special_operations_with_properties.phpt @@ -0,0 +1,68 @@ +--TEST-- +Special operations with XSLTProcessor properties +--EXTENSIONS-- +xsl +dom +--FILE-- +loadXML('hello'); + +function test() { + echo "Called test\n"; +} + +$xsl = new DOMDocument; +$xsl->loadXML(<< + + + + + + +XML); + +echo "--- Unset cloneDocument ---\n"; + +$xslt = new XSLTProcessor; +$xslt->registerPHPFunctions(); +unset($xslt->cloneDocument); +try { + $xslt->importStylesheet($xsl); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +echo "--- Unset doXInclude ---\n"; + +$xslt = new XSLTProcessor; +$xslt->registerPHPFunctions(); +unset($xslt->doXInclude); +$xslt->importStylesheet($xsl); +try { + echo $xslt->transformToXml($xml); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +echo "--- Make properties references ---\n"; + +$xslt = new XSLTProcessor; +$xslt->registerPHPFunctions(); +$clone =& $xslt->cloneDocument; +$xinclude =& $xslt->doXInclude; +$xslt->importStylesheet($xsl); +echo $xslt->transformToXml($xml); + +?> +--EXPECT-- +--- Unset cloneDocument --- +Typed property XSLTProcessor::$cloneDocument must not be accessed before initialization +--- Unset doXInclude --- +Typed property XSLTProcessor::$doXInclude must not be accessed before initialization +--- Make properties references --- +Called test + +hello