|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43312 php://filter URIs get mangled and make xinclude() fail
Submitted: 2007-11-16 13:42 UTC Modified: 2008-02-01 13:12 UTC
From: php at benjaminschulz dot com Assigned: chregu (profile)
Status: Wont fix Package: DOM XML related
PHP Version: 5.3CVS-2007-11-16 (CVS) OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-11-16 13:42 UTC] php at benjaminschulz dot com
When using php://filter with xinclude an errornous file:// uri is 
generated and let's the xinclude fail. 

Reproduce code:
echo '<pre>';

class TestFilter extends PHP_User_Filter {
    public function filter($in, $out, &$consumed, $closing) {
        while ($bucket = stream_bucket_make_writeable($in)) {
            $consumed += $bucket->datalen;
            stream_bucket_append($out, $bucket);
        return PSFS_PASS_ON;
stream_filter_register('testfilter', 'TestFilter');

$doc = new DomDocument;
echo "works!";

<?xml version="1.0" encoding="UTF-8"?>
    <xi:include href="test2.xml" xmlns:xi="" />

<?xml version="1.0" encoding="UTF-8"?>

Expected result:

Actual result:
/to/test2.xml): failed to open stream: No such file or directory in 
/path/to/test.php on line 18
^- should be ":" and there are two slashes missing

Warning: DOMDocument::xinclude(): I/O warning : failed to load external 
entity "php://filter/read=testfilter/resource=file%3A/path/to/test2.xml" 
in /path/to/test.php on line 18

Warning: DOMDocument::xinclude(): could not load 
php://filter/read=testfilter/resource=file%3A/path/to/test2.xml, and no 
fallback was found in /path/to/test.php on line 18


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-01 13:12 UTC]
PHP URL handling for streams is not fully compatible with libxml2 URL handling and canonicalization routines.
Workaround is to use a relative path for that case:
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Feb 29 23:01:30 2024 UTC