php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46432 xml_parse_into_struct() doesn't return correct data
Submitted: 2008-10-30 16:33 UTC Modified: 2008-11-10 13:41 UTC
From: jmpons at arenamobile dot com Assigned: rrichards (profile)
Status: Not a bug Package: XML related
PHP Version: 5.2CVS-2008-10-31 OS: *
Private report: No CVE-ID: None
 [2008-10-30 16:33 UTC] jmpons at arenamobile dot com
Description:
------------
With php 5.2.6, parsing xml code with html inside, return a bad parsed string...

I have checked it with php 5.2.5 and it works fine...


Reproduce code:
---------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<tree>
<node>bla bla bla &lt;br/&gt; &lt;a href="http://www.google.com"&gt;url&lt;/a&gt; blah...</node>
</tree>

<?php
$file = "test.xml";
$data = implode("", file($file));
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $values, $tags);
xml_parser_free($parser);
print_r($values);
?>

Expected result:
----------------
Array
(
    [0] => Array
        (
            [tag] => tree
            [type] => open
            [level] => 1
        )

    [1] => Array
        (
            [tag] => node
            [type] => complete
            [level] => 2
            [value] => bla bla bla <br/><a href="http://www.google.com">url</a> blah...
        )

    [2] => Array
        (
            [tag] => tree
            [type] => close
            [level] => 1
        )

)


Actual result:
--------------
Array
(
    [0] => Array
        (
            [tag] => tree
            [type] => open
            [level] => 1
        )

    [1] => Array
        (
            [tag] => node
            [type] => complete
            [level] => 2
            [value] => bla bla bla br/a href="http://www.google.com"url/a blah...
        )

    [2] => Array
        (
            [tag] => tree
            [type] => close
            [level] => 1
        )

)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-31 18:04 UTC] jani@php.net
Tested by compiling with libexpat and it works. When compiled with libxml it does not work. So it's just incompatibility between libexpat and libxml. Rob, can you check this out?
 [2008-11-03 17:00 UTC] rrichards@php.net
Do you happen to be using libxml2 2.7.x when testing with 5.2.6?
If so, this is the same as bug #45996.
 [2008-11-10 12:37 UTC] jmpons at arenamobile dot com
Oh, I didn't know there was this bug opened already, I did not find it when I did the search. My apologies.

I will follow the other bug to see possible solutions and how this is evolving. Thanks to you a lot.
 [2008-11-10 13:41 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: Wed Apr 24 08:01:29 2024 UTC