]> granicus.if.org Git - php/commitdiff
Avoid warning on exception in xsl ext
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 25 Jun 2020 13:06:53 +0000 (15:06 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 25 Jun 2020 13:07:38 +0000 (15:07 +0200)
ext/xsl/tests/bug33853.phpt
ext/xsl/tests/throw_in_autoload.phpt [new file with mode: 0644]
ext/xsl/xsltprocessor.c

index a2e835ff6d484ef60dd3da80f14351e4f98ee1d1..815ea03a257686d79ff2c5a8284473417fa844d9 100644 (file)
@@ -9,8 +9,8 @@ if (getenv('SKIP_ASAN')) die('xfail bailing out across foreign C code');
 <?php
 
 spl_autoload_register(function ($className) {
-        var_dump($className);
-        exit();
+    var_dump($className);
+    exit();
 });
 
 $xsl = new DomDocument();
diff --git a/ext/xsl/tests/throw_in_autoload.phpt b/ext/xsl/tests/throw_in_autoload.phpt
new file mode 100644 (file)
index 0000000..e0f441d
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+Fork of bug33853.phpt with exit replaced by throw
+--SKIPIF--
+<?php
+if (!extension_loaded('xsl')) die('skip xsl not loaded');
+?>
+--FILE--
+<?php
+
+spl_autoload_register(function ($className) {
+    var_dump($className);
+    throw new Exception("Autoload exception");
+});
+
+$xsl = new DomDocument();
+$xsl->loadXML('<?xml version="1.0" encoding="iso-8859-1" ?>
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:php="http://php.net/xsl">
+<xsl:template match="/">
+<xsl:value-of select="php:function(\'TeSt::dateLang\')" />
+</xsl:template>
+</xsl:stylesheet>');
+$inputdom = new DomDocument();
+$inputdom->loadXML('<?xml version="1.0" encoding="iso-8859-1" ?>
+<today></today>');
+
+$proc = new XsltProcessor();
+$proc->registerPhpFunctions();
+$xsl = $proc->importStylesheet($xsl);
+try {
+    $newdom = $proc->transformToDoc($inputdom);
+} catch (Exception $e) {
+    echo $e->getMessage(), "\n";
+}
+?>
+===DONE===
+--EXPECT--
+string(4) "TeSt"
+Autoload exception
+===DONE===
index 6693ac402165ab9346025e148ee29ddaabcc9b5e..968ed2f3d7fcf647570b1eb8f5a3f9e8dbdf4eb4 100644 (file)
@@ -248,7 +248,9 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
        fci.no_separation = 0;
        /*fci.function_handler_cache = &function_ptr;*/
        if (!zend_make_callable(&handler, &callable)) {
-               php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable));
+               if (!EG(exception)) {
+                       php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable));
+               }
                valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));
        } else if ( intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) {
                php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'", ZSTR_VAL(callable));