php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75475 Libxml 2.9.6 breaks custom stream wrappers in XSLT
Submitted: 2017-11-02 14:50 UTC Modified: -
Votes:6
Avg. Score:5.0 ± 0.0
Reproduced:5 of 5 (100.0%)
Same Version:5 (100.0%)
Same OS:4 (80.0%)
From: alexey dot belkov at umisoft dot ru Assigned:
Status: Open Package: XSLT related
PHP Version: 7.1.11 OS: macOS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alexey dot belkov at umisoft dot ru
New email:
PHP Version: OS:

 

 [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

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Oct 15 23:01:26 2019 UTC