|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6146 xml_parse() passes character entities incorrectly
Submitted: 2000-08-14 07:45 UTC Modified: 2001-02-19 06:30 UTC
From: Assigned:
Status: Closed Package: XML related
PHP Version: 4.0 Latest CVS (14/08/2000) OS: Sun Solaris 2.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2000-08-14 07:45 UTC]
Here are an example xml-file and php-script which demonstrates
this behaviour:

<?xml version="1.0" ?>



$file = "test.xml";

function characterData($parser, $data) {
    print "*$data*<br>";

$xml_parser = xml_parser_create();
xml_set_character_data_handler($xml_parser, "characterData");

if (!($fp = fopen($file, "r"))) {
    die("could not open XML input");

while ($data = fread($fp, 4096)) {

    if (!xml_parse($xml_parser, $data, feof($fp))) {
        die(sprintf("XML error: %s at line %d",



php configure line:

--prefix=/data --with-config-file-path=/data/conf  
--without-gd --disable-pear

And the output with those files:
* *
* *
* *
* *
* *



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-15 08:51 UTC]
what is wrong with the output?

 [2001-02-19 06:03 UTC]
Try the code. It shows what happens. The output should be same for
both test cases (the one with entitities breaks, ie. every entity is considered
a string itself)

I'm not sure if this is a bug in PHP but more likely in expat library itself.


 [2001-02-19 06:30 UTC]
that's the way expat works - you are never guaranteed that 
cdata is deliverd to the callback in one piece.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 08 06:03:33 2021 UTC