php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47117 wrong XML parse, loss chars
Submitted: 2009-01-15 17:24 UTC Modified: 2009-01-22 14:06 UTC
Votes:4
Avg. Score:5.0 ± 0.0
Reproduced:2 of 3 (66.7%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: dir at melbis dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.2.8 OS: FreeBSD 7.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dir at melbis dot com
New email:
PHP Version: OS:

 

 [2009-01-15 17:24 UTC] dir at melbis dot com
Description:
------------
When parsing XML, chars "<" and ">" was gone...
For sample, Tag has "&lt;STRONG&gt;", but outside wrong value: "STRONG", must be "<STRONG>"

Reproduce code:
---------------
$data = '<MELBISSHOP Version="5.4.0"><DO KeyValues="1242"><descr>&lt;STRONG&gt;</descr></DO></MELBISSHOP>';
$xml_parser = xml_parser_create('UTF-8');
xml_set_element_handler($xml_parser, "start_xml_tag", "end_xml_tag");
xml_set_character_data_handler($xml_parser, "xml_tag");
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, FALSE);
xml_parse($xml_parser, $data, true);
function start_xml_tag($mParser, $mName, $mAttrs) { 
global $gDoValues, $gCurrentTagName;
$gCurrentTagName = $mName;
if ( $mName != 'DO' ) { $gDoValues[$gCurrentTagName] = ''; } else { $gDoValues = array(); } }
function xml_tag($mParser, $mData) { 
global $gDoValues, $gCurrentTagName;
$gDoValues[$gCurrentTagName] .= $mData;}
function end_xml_tag($mParser, $mName) {
global $gDoValues, $gData;
if ($mName == 'DO') { print_r($gDoValues); }}

Expected result:
----------------
Array
(
    [descr] => <STRONG>
)




Actual result:
--------------
Array
(
    [descr] => STRONG
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-15 19:23 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-01-22 13:29 UTC] dm at vfh dot de
I solved the problem by downgrading libxml2 from 2.7.2 to 2.6.32.
See also: http://bugs.php.net/bug.php?id=45996
 [2009-01-22 14:06 UTC] rrichards@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.

duplicate of bug #45996
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 11:01:30 2024 UTC