php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69910 relaxNGValidate() + libxml_disable_entity_loader don't work as expected.
Submitted: 2015-06-23 10:31 UTC Modified: 2015-06-23 10:33 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:2 (50.0%)
From: tamerlaha at gmail dot com Assigned:
Status: Open Package: *XML functions
PHP Version: 5.5.26 OS: Ubuntu
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-06-23 10:31 UTC] tamerlaha at gmail dot com
Description:
------------
Script should return nothing if validation was successful.

With libxml_disable_entity_loader(False) it works as expected.

with libxml_disable_entity_loader(true);
Raise "failed to load external entity." and validation fails.

why is schema considered like external entity?




Test script:
---------------
<?php
libxml_use_internal_errors(true);
libxml_disable_entity_loader(true);

$contents = file_get_contents("zbx_screens_export.xml");
$xml = new DOMDocument();
                if(!$xml->loadXML($contents)){
                        $errors = libxml_get_errors();
                        print_r ($errors);};

$result = $xml->relaxNGValidate("screens.rng");
                if(!$result){
                        $errors = libxml_get_errors();
                        print_r ($errors);
                        };
?>



screens.rng  http://pastebin.com/QTV6MHaw 
zbx_screens_export.xml http://pastebin.com/AkcpLzwn


Actual result:
--------------
PHP Warning:  DOMDocument::relaxNGValidate(): Invalid RelaxNG in /home/tamerlan/relaxng.php on line 11
Array
(
    [0] => LibXMLError Object
        (
            [level] => 1
            [code] => 1549
            [column] => 0
            [message] => failed to load external entity "screens.rng"

            [file] => 
            [line] => 0
        )

    [1] => LibXMLError Object
        (
            [level] => 2
            [code] => 1065
            [column] => 0
            [message] => xmlRelaxNGParse: could not load screens.rng

            [file] => 
            [line] => 0
        )

)


Patches

vnrauwlc (last revision 2015-07-16 12:07 UTC by sample at email dot tst)
blqcykmi (last revision 2015-07-16 12:02 UTC by sample at email dot tst)
tgoeylwo (last revision 2015-07-16 11:56 UTC by sample at email dot tst)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-23 10:33 UTC] tamerlaha at gmail dot com
libxml2 version is  2.9.1+dfsg1-3ubuntu4.4
PHP 5.5.26-1+deb.sury.org~trusty+1 (cli) (built: Jun 15 2015 10:13:03)
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Oct 18 21:01:27 2019 UTC