Bug #69910 [Opn]: relaxNGValidate() + libxml_disable_entity_loader don't work as expected.

From: Date: Tue, 23 Jun 2015 10:33:19 +0000
Subject: Bug #69910 [Opn]: relaxNGValidate() + libxml_disable_entity_loader don't work as expected.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193792@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69910&edit=1

 ID:                 69910
 User updated by:    tamerlaha at gmail dot com
 Reported by:        tamerlaha at gmail dot com
 Summary:            relaxNGValidate() + libxml_disable_entity_loader
                     don't work as expected.
 Status:             Open
 Type:               Bug
 Package:            *XML functions
 Operating System:   Ubuntu
 PHP Version:        5.5.26
 Block user comment: N
 Private report:     N

 New Comment:

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)


Previous Comments:
------------------------------------------------------------------------
[2015-06-23 10:31:37] 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
        )

)



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=69910&edit=1


Thread (3 messages)

« previous php.bugs (#193792) next »