Req #51939 [PATCH]: Add xml_set_entity_decl_handler function

From: Date: Tue, 19 Jul 2011 16:21:20 +0000
Subject: Req #51939 [PATCH]: Add xml_set_entity_decl_handler function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-162009@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=51939&edit=1

 ID:                 51939
 Patch added by:     davidc@php.net
 Reported by:        mchenryc at gmail dot com
 Summary:            Add xml_set_entity_decl_handler function
 Status:             Assigned
 Type:               Feature/Change Request
 Package:            XML related
 PHP Version:        trunk-SVN-2010-05-28 (SVN)
 Assigned To:        davidc
 Block user comment: N
 Private report:     N

 New Comment:

The following patch has been added/updated:

Patch Name: bug51939.patch
Revision:   1311092480
URL:        https://bugs.php.net/patch-display.php?bug=51939&patch=bug51939.patch&revision=1311092480


Previous Comments:
------------------------------------------------------------------------
[2010-05-28 01:40:45] mchenryc at gmail dot com

Description:
------------
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).

http://expat.cvs.sourceforge.net/viewvc/expat/expat/lib/expat.h?
revision=1.80&view=markup#l_311

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", 
				 xml_error_string(xml_get_error_code($parser)),
				 xml_get_current_line_number($parser)));
xml_parser_free($parser);


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()



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



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


Thread (10 messages)

« previous php.bugs (#162009) next »