|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51939 Add xml_set_entity_decl_handler function
Submitted: 2010-05-28 01:40 UTC Modified: 2011-07-19 12:22 UTC
Avg. Score:3.3 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: mchenryc at gmail dot com Assigned: davidc
Status: Assigned Package: XML related
PHP Version: trunk-SVN-2010-05-28 (SVN) OS:
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-05-28 01:40 UTC] mchenryc at gmail dot com
When parsing XML, PHP has no way to set a handler for general entities, though a 
handler can be set for unparsed entities.

Expat has deprecated the XML_SetUnparsedEntityDeclHandler in favor of 
XML_SetEntityDeclHandler, which is called for all entity types (including general 
and unparsed).

PHP should add the xml_set_entity_decl_handler function to allow handling of all 
entity declarations.

Test script:
$data = '<!DOCTYPE test [<!ENTITY generalEntity "General Entity">]><test>&generalEntity;</test>';

function h_entity_decl($parser,$entity_name,$is_parameter_entity,$value,$base,$system_id,$public_id,$notation_name) {
	echo "$entity_name - $is_parameter_entity - $value";

$parser = xml_parser_create();
xml_set_entity_decl_handler($parser, 'h_entity_decl');

xml_parse($parser,$data,false) or 
    die (sprintf("XML Error: %s at line %d<br>\n", 

Expected result:
It should run with the following output:

generalEntity - 0 - General Entity

Actual result:
Fatal Error: Call to undefined function xml_set_entity_decl_handler()


Bug51939.patch (last revision 2011-07-21 13:03 UTC) by
bug51939-3-ws.patch (last revision 2011-07-21 12:43 UTC) by
bug51392-ws (last revision 2011-07-21 12:39 UTC) by
bug51939.patch (last revision 2011-07-19 16:21 UTC) by

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-15 07:23 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: davidc
 [2011-07-19 12:21 UTC]
The following patch has been added/updated:

Patch Name: bug51939.patch
Revision:   1311092480
 [2011-07-19 12:22 UTC]
I've added a patch for this but I'd like to write a few more tests before committing it. If you could apply it and let me know if this helps you that'd be 
 [2011-07-21 08:39 UTC]
The following patch has been added/updated:

Patch Name: bug51392-ws
Revision:   1311251978
 [2011-07-21 08:43 UTC]
The following patch has been added/updated:

Patch Name: bug51939-3-ws.patch
Revision:   1311252230
 [2011-07-21 09:03 UTC]
The following patch has been added/updated:

Patch Name: Bug51939.patch
Revision:   1311253426
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 17:01:31 2015 UTC