|
| 1 | +--TEST-- |
| 2 | +bug #49634 (Segfault throwing an exception in a XSL registered function) |
| 3 | +--SKIPIF-- |
| 4 | +<?php |
| 5 | +extension_loaded("xsl") or die("skip need ext/xsl"); |
| 6 | +?> |
| 7 | +--FILE-- |
| 8 | +<?php |
| 9 | + |
| 10 | +$sXml = <<<XML |
| 11 | +<?xml version="1.0" encoding="UTF-8" ?> |
| 12 | +<root> |
| 13 | + test |
| 14 | +</root> |
| 15 | +XML; |
| 16 | + |
| 17 | +$cDIR = __DIR__; |
| 18 | +$sXsl = <<<XSL |
| 19 | +<xsl:stylesheet version="1.0" |
| 20 | + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 21 | + xmlns:ext="http://php.net/xsl" |
| 22 | + xsl:extension-element-prefixes="ext" |
| 23 | + exclude-result-prefixes="ext"> |
| 24 | + <xsl:output encoding="UTF-8" indent="yes" method="xml" /> |
| 25 | + <xsl:template match="/"> |
| 26 | + <xsl:value-of select="ext:function('testFunction', document('$cDIR/bug49634.xml')/root)"/> |
| 27 | + </xsl:template> |
| 28 | +</xsl:stylesheet> |
| 29 | +XSL; |
| 30 | + |
| 31 | +function testFunction($a) |
| 32 | +{ |
| 33 | + throw new Exception('Test exception.'); |
| 34 | +} |
| 35 | + |
| 36 | +$domXml = new DOMDocument; |
| 37 | +$domXml->loadXML($sXml); |
| 38 | +$domXsl = new DOMDocument; |
| 39 | +$domXsl->loadXML($sXsl); |
| 40 | + |
| 41 | +for ($i = 0; $i < 10; $i++) |
| 42 | +{ |
| 43 | + $xsltProcessor = new XSLTProcessor(); |
| 44 | + $xsltProcessor->registerPHPFunctions(array('testFunction')); |
| 45 | + $xsltProcessor->importStyleSheet($domXsl); |
| 46 | + try { |
| 47 | + @$xsltProcessor->transformToDoc($domXml); |
| 48 | + } catch (Exception $e) { |
| 49 | + echo $e,"\n"; |
| 50 | + } |
| 51 | +} |
| 52 | +?> |
| 53 | +===DONE=== |
| 54 | +--EXPECTF-- |
| 55 | +exception 'Exception' with message 'Test exception.' in %s:%d |
| 56 | +Stack trace: |
| 57 | +#0 [internal function]: testFunction(Array) |
| 58 | +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) |
| 59 | +#2 {main} |
| 60 | +exception 'Exception' with message 'Test exception.' in %s:%d |
| 61 | +Stack trace: |
| 62 | +#0 [internal function]: testFunction(Array) |
| 63 | +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) |
| 64 | +#2 {main} |
| 65 | +exception 'Exception' with message 'Test exception.' in %s:%d |
| 66 | +Stack trace: |
| 67 | +#0 [internal function]: testFunction(Array) |
| 68 | +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) |
| 69 | +#2 {main} |
| 70 | +exception 'Exception' with message 'Test exception.' in %s:%d |
| 71 | +Stack trace: |
| 72 | +#0 [internal function]: testFunction(Array) |
| 73 | +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) |
| 74 | +#2 {main} |
| 75 | +exception 'Exception' with message 'Test exception.' in %s:%d |
| 76 | +Stack trace: |
| 77 | +#0 [internal function]: testFunction(Array) |
| 78 | +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) |
| 79 | +#2 {main} |
| 80 | +exception 'Exception' with message 'Test exception.' in %s:%d |
| 81 | +Stack trace: |
| 82 | +#0 [internal function]: testFunction(Array) |
| 83 | +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) |
| 84 | +#2 {main} |
| 85 | +exception 'Exception' with message 'Test exception.' in %s:%d |
| 86 | +Stack trace: |
| 87 | +#0 [internal function]: testFunction(Array) |
| 88 | +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) |
| 89 | +#2 {main} |
| 90 | +exception 'Exception' with message 'Test exception.' in %s:%d |
| 91 | +Stack trace: |
| 92 | +#0 [internal function]: testFunction(Array) |
| 93 | +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) |
| 94 | +#2 {main} |
| 95 | +exception 'Exception' with message 'Test exception.' in %s:%d |
| 96 | +Stack trace: |
| 97 | +#0 [internal function]: testFunction(Array) |
| 98 | +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) |
| 99 | +#2 {main} |
| 100 | +exception 'Exception' with message 'Test exception.' in %s:%d |
| 101 | +Stack trace: |
| 102 | +#0 [internal function]: testFunction(Array) |
| 103 | +#1 %s(%d): XSLTProcessor->transformToDoc(Object(DOMDocument)) |
| 104 | +#2 {main} |
| 105 | +===DONE=== |
0 commit comments