Bug #71592 [Opn->Ver]: External entity processing never fail regardless of handler return code

From: Date: Wed, 14 Mar 2018 17:45:43 +0000
Subject: Bug #71592 [Opn->Ver]: External entity processing never fail regardless of handler return code
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214357@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71592&edit=1 ID: 71592 Updated by: cmb@php.net Reported by: anrdaemon at freemail dot ru Summary: External entity processing never fail regardless of handler return code -Status: Open +Status: Verified Type: Bug Package: XML related Operating System: Windows PHP Version: 5.6.18 Block user comment: N Private report: N New Comment: This part of the documentation refers to libexpat based ext/xml. For libxml2 based ext/xml, the external entity reference handler is effectively a void function. Not sure, whether libexpat's behavior could be implemented with libxml2. Previous Comments: ------------------------------------------------------------------------ [2016-02-15 01:39:53] anrdaemon at freemail dot ru Description: ------------ Despite documentation[1] explicitly stating that "If the value returned from the handler is FALSE (which it will be if no value is returned), the XML parser will stop parsing and xml_get_error_code() will return XML_ERROR_EXTERNAL_ENTITY_HANDLING.", the output of the attached test script will always be "No error". phpinfo() PHP Version => 5.6.18 xml XML Support => active XML Namespace Support => active libxml2 Version => 2.9.3 [1]http://php.net/xml_set_external_entity_ref_handler Test script: --------------- <?php $parser = xml_parser_create_ns('UTF-8'); xml_set_external_entity_ref_handler($parser, function($self, $names, $base, $system_id, $public_id) { print "@{$names}: '{$system_id}' {$public_id}\n"; /* Ref: http://php.net/xml_set_external_entity_ref_handler If the value returned from the handler is FALSE (which it will be if no value is returned), the XML parser will stop parsing and xml_get_error_code() will return XML_ERROR_EXTERNAL_ENTITY_HANDLING. */ return false; } ); xml_parse($parser, '<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE p [ <!ENTITY pic PUBLIC "image.gif" "http://example.org/image.gif"> ]> <p>&pic;</p>'); print xml_error_string(xml_get_error_code($parser)) . "\n"; ?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71592&edit=1

« previous php.bugs (#214357) next »