Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- bug #49634 (Segfault throwing an exception in a XSL registered function) --EXTENS..

Decoded Output download

--TEST--
bug #49634 (Segfault throwing an exception in a XSL registered function)
--EXTENSIONS--
xsl
--FILE--
<?php

$sXml = <<<XML
<?xml version="1.0" encoding="UTF-8" ?>
<root>
    test
</root>
XML;

$cDIR = __DIR__;
$sXsl = <<<XSL
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:ext="http://php.net/xsl"
                xsl:extension-element-prefixes="ext"
                exclude-result-prefixes="ext">
    <xsl:output encoding="UTF-8" indent="yes" method="xml" />
    <xsl:template match="/">
        <xsl:value-of select="ext:function('testFunction', document('$cDIR/bug49634.xml')/root)"/>
    </xsl:template>
</xsl:stylesheet>
XSL;

function testFunction($a)
{
        throw new Exception('Test exception.');
}

$domXml = new DOMDocument;
$domXml->loadXML($sXml);
$domXsl = new DOMDocument;
$domXsl->loadXML($sXsl);

for ($i = 0; $i < 10; $i++)
{
    $xsltProcessor = new XSLTProcessor();
    $xsltProcessor->registerPHPFunctions(array('testFunction'));
    $xsltProcessor->importStyleSheet($domXsl);
    try {
        @$xsltProcessor->transformToDoc($domXml);
    } catch (Exception $e) {
        echo $e,"
";
    }
}
?>
--EXPECTF--
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}

Did this file decode correctly?

Original Code

--TEST--
bug #49634 (Segfault throwing an exception in a XSL registered function)
--EXTENSIONS--
xsl
--FILE--
<?php

$sXml = <<<XML
<?xml version="1.0" encoding="UTF-8" ?>
<root>
    test
</root>
XML;

$cDIR = __DIR__;
$sXsl = <<<XSL
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:ext="http://php.net/xsl"
                xsl:extension-element-prefixes="ext"
                exclude-result-prefixes="ext">
    <xsl:output encoding="UTF-8" indent="yes" method="xml" />
    <xsl:template match="/">
        <xsl:value-of select="ext:function('testFunction', document('$cDIR/bug49634.xml')/root)"/>
    </xsl:template>
</xsl:stylesheet>
XSL;

function testFunction($a)
{
        throw new Exception('Test exception.');
}

$domXml = new DOMDocument;
$domXml->loadXML($sXml);
$domXsl = new DOMDocument;
$domXsl->loadXML($sXsl);

for ($i = 0; $i < 10; $i++)
{
    $xsltProcessor = new XSLTProcessor();
    $xsltProcessor->registerPHPFunctions(array('testFunction'));
    $xsltProcessor->importStyleSheet($domXsl);
    try {
        @$xsltProcessor->transformToDoc($domXml);
    } catch (Exception $e) {
        echo $e,"\n";
    }
}
?>
--EXPECTF--
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}
Exception: Test exception. in %s:%d
Stack trace:
#0 [internal function]: testFunction(Array)
#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument))
#2 {main}

Function Calls

None

Variables

$sXml <?xml version="1.0" encoding="UTF-8" ?> <root> test </ro..

Stats

MD5 9fe2bdd7a80511c5122ff5bb8d6eafc5
Eval Count 0
Decode Time 83 ms