php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69491 simplexml doesn't correctly parse empty nodes on same line as another node
Submitted: 2015-04-21 02:33 UTC Modified: 2015-05-27 17:50 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: ray dot ward at bigcommerce dot com Assigned: cmb (profile)
Status: Duplicate Package: SimpleXML related
PHP Version: 5.6.8 OS: Debian
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ray dot ward at bigcommerce dot com
New email:
PHP Version: OS:

 

 [2015-04-21 02:33 UTC] ray dot ward at bigcommerce dot com
Description:
------------
This is very similar to https://bugs.php.net/bug.php?id=66084

When an empty node is within another node on the same line of a multi-line xml file, the empty node name gets parsed as an integer.

If the empty node gets moved to its own line, then it gets parsed correctly.

This previously worked in PHP 5.3, now fails in 5.4, 5.5 and 5.6.

Test script:
---------------
FAILS:

var_dump(simplexml_load_string('<a>
  <b><c/></b>
</a>'));

WORKS:

var_dump(simplexml_load_string('<a>
  <b>
    <c/>
  </b>
</a>'));

Expected result:
----------------
object(SimpleXMLElement)#1 (1) {
  ["b"]=>
  object(SimpleXMLElement)#3 (1) {
    ["c"]=>
    object(SimpleXMLElement)#2 (0) {
    }
  }
}

Actual result:
--------------
object(SimpleXMLElement)#1 (1) {
  ["b"]=>
  object(SimpleXMLElement)#3 (1) {
    [0]=>
    object(SimpleXMLElement)#2 (0) {
    }
  }
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-24 01:15 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2015-04-24 01:15 UTC] cmb@php.net
Compare <http://3v4l.org/7aTML> vs. <http://3v4l.org/vFdbY>.
 [2015-04-24 03:13 UTC] ray dot ward at bigcommerce dot com
The issue looks like it can be generalised to just problems with whitespace parsing, rather than lines.

broken: http://3v4l.org/66O5Y
working: http://3v4l.org/C0JVE
 [2015-05-27 17:50 UTC] cmb@php.net
-Status: Verified +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2015-05-27 17:50 UTC] cmb@php.net
After further investigation it turned out that this is a duplicate
of bug #66084.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 16:01:29 2024 UTC