php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32441 Tags and entity references in entities are not parsed
Submitted: 2005-03-24 13:13 UTC Modified: 2005-03-24 18:34 UTC
From: joern_h at gmx dot net Assigned:
Status: Not a bug Package: XML related
PHP Version: 5CVS-2005-03-24 (dev) OS: Windows 2000
Private report: No CVE-ID:
 [2005-03-24 13:13 UTC] joern_h at gmx dot net
Description:
------------
When the replacement for an entity contains xml tags or another entity these do not get parsed by PHP5. Such constructs are used for example inside the PHP documentation to mark up often used strings like warnings and section titles. This code works in PHP4.

Reproduce code:
---------------
<?php

error_reporting(E_ALL);

$xml = <<<HERE
<!DOCTYPE test [
    <!ENTITY test "<abc>&amp;</abc>">
]>
<test>&test;</test>
HERE;

function startHandler($parser, $name, $attrs) {print("StartHandler Called\n");}
function endHandler($parser, $name) {print("EndHandler Called\n");}
function characterHandler($parser, $data) {echo "Character: $data\n";}

$parser =& xml_parser_create('');
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);

xml_set_element_handler($parser, 'startHandler', 'endHandler');
xml_set_character_data_handler($parser, 'characterHandler');

if (!xml_parse($parser, $xml, true))
    echo xml_error_string($parser);

xml_parser_free($parser);

?>


Expected result:
----------------
StartHandler Called
StartHandler Called
Character: &
EndHandler Called
EndHandler Called

Actual result:
--------------
StartHandler Called
Character: <abc>&amp;</abc>
EndHandler Called

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-24 18:34 UTC] sniper@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

See bug #27908


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 12:01:52 2014 UTC