summaryrefslogtreecommitdiff
path: root/ext/xsl/tests/bug49634.phpt
blob: edf53ba6008535ba8f3f506c89250de0e7f85768 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
--TEST--
bug #49634 (Segfault throwing an exception in a XSL registered function)
--SKIPIF--
<?php
extension_loaded("xsl") or die("skip need ext/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}