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: 2020-08-31 16:00 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: cmb (profile)
Status: Duplicate Package: *XML functions
PHP Version: 5.5.26 OS: Ubuntu
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 you forgot your password, you can retrieve your password here.
Password:
Status:
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)

Pull Requests

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)
 [2020-08-31 16:00 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2020-08-31 16:00 UTC] cmb@php.net
Basically a duplicate of bug #62577.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 21:01:28 2024 UTC