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:3
Avg. Score:4.3 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tamerlaha at gmail dot com
New email:
PHP Version: OS:

 

 [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-2018 The PHP Group
All rights reserved.
Last updated: Sat Sep 22 08:01:25 2018 UTC