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: 2021-07-07 11:37 UTC
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: cmb (profile)
Status: Not a bug Package: XSLT related
PHP Version: 7.1.11 OS: macOS
Private report: No CVE-ID: None
 [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

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-07 11:37 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-07-07 11:37 UTC] cmb@php.net
If the regression happened in libxml2 2.9.6 or 2.9.5, this doesn't
appear to be a PHP issue at all.  If still relevant, consider to
file a bug report upstream[1].

[1] <http://xmlsoft.org/bugs.html>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 13:01:28 2024 UTC