php.net |  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: sniper@php.net 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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
34 - 27 = ?
Subscribe to this entry?

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

<?xml version="1.0" ?>
<document>
<test1>??????</test1>
<test2>&#229;&#228;&#246;&#197;&#196;&#214;</test2>
</document>

---------

<?php

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

?>

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

php configure line:

./configure 
--prefix=/data --with-config-file-path=/data/conf  
--with-mysql=/data/kolumbustori
--without-gd --disable-pear
--disable-debug

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

--Jani

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

 [2001-02-19 06:03 UTC] sniper@php.net
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.

--Jani

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



 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 11:01:30 2024 UTC