Anyone can comment on a bug. Have a simpler test case? Does it
work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please
— but make sure to vote on the bug!

Your email address:MUST BE VALID

Solve the problem:36 - 9 = ?

Subscribe to this entry?

[2017-11-02 14:50 UTC] alexey dot belkov at umisoft dot ru

Description:
------------
I'm working on a CMS that uses custom stream wrappers extensively in XSL templates. We received a bug report from one of our users who installed PHP with Homebrew on macOS, which includes the newest version of libxml 2.9.6. For some reason, this particular version breaks all our XSL templates, which worked fine on 2.9.4. (2.9.5 may also be broken but I didn't check this myself.)
Here's essentially what's happening. We register a custom stream wrapper and use it in XSLT to load external entities and include XSL files dynamically. The custom stream _works_ in the main XSL template to load external entities, but it doesn't work inside <xsl:include>. Also it doesn't work in the included XSL template to load external entities.
I reproduced this on a fresh PHP install from homebrew:
PHP Version 7.1.11
libxml Version 2.9.6
libxslt Version 1.1.29
libxslt compiled against libxml Version 2.9.4
Test script:
---------------
The whole thing: https://github.com/ltongues/cms2-2053
The main script:
include 'CustomStreamWrapper.php';
stream_wrapper_register('custom', 'CustomStreamWrapper');
$xml = new DOMDocument();
$xml->load('test.xml');
$xsl = new DOMDocument();
$xsl->resolveExternals = true;
$xsl->substituteEntities = true;
$xsl->load('main.xsl');
$proc = new XSLTProcessor();
$proc->importStyleSheet($xsl); // compilation error
Actual result:
--------------
1)
Warning: XSLTProcessor::importStylesheet(): compilation error: file /Users/knots/Sites/cms2-2053/main.xsl line 20 element include in /Users/knots/Sites/cms2-2053/index.php on line 15
Warning: XSLTProcessor::importStylesheet(): xsl:include : unable to load custom://localhost/customInclude.xsl in /Users/knots/Sites/cms2-2053/index.php on line 15
2)
Warning: XSLTProcessor::importStylesheet(): compilation error: file /Users/knots/Sites/cms2-2053/include.xsl line 16 element text in /Users/knots/Sites/cms2-2053/index.php on line 15
Warning: XSLTProcessor::importStylesheet(): xsltParseTemplateContent: xslt:text content problem in /Users/knots/Sites/cms2-2053/index.php on line 15