Bug #66084 [NEW]: simplexml_load_string() mangles empty node name

From: Date: Tue, 12 Nov 2013 17:31:17 +0000
Subject: Bug #66084 [NEW]: simplexml_load_string() mangles empty node name
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182720@lists.php.net to get a copy of this message
From: php at kenman dot net Operating system: Win7 PHP version: 5.5Git-2013-11-12 (snap) Package: SimpleXML related Bug Type: Bug Bug description:simplexml_load_string() mangles empty node name Description: ------------ Since PHP 5.4.16 (at least), simplexml_load_string() incorrectly interprets some XML strings. For specific inputs with empty nodes, node names are converted to integers. Works as expected in 5.3.10 (libxml 2.7.7); does not work as expected in 5.4.16 (libxml 2.7.8) or 5.5.6-dev (libxml 2.9.1). Seems to be related to libxml2's xmlReadMemory(), though don't quote me on that. Further observations: * Removing the <b/> node results in the expected output, though otherwise manipulating <b/> (adding text content, including a closing tag, etc.) has no effect. * Changing the problematic node to non-selfclosing has no effect. * Adding a value to <x>, such as <x>1</x>, results in the expected output. * Adding an attribute to <x> has no effect. * Including the XML prologue has no effect. * libxml_use_internal_errors(true) does not report any errors. * The libxml option LIBXML_NOEMPTYTAG seems to have no effect. Test script: --------------- var_dump(simplexml_load_string('<a><b/><c><x/></c></a>')->c); Expected result: ---------------- object(SimpleXMLElement)#2 (1) { ["x"]=> object(SimpleXMLElement)#3 (0) { } } Actual result: -------------- object(SimpleXMLElement)#2 (1) { [0]=> object(SimpleXMLElement)#3 (1) { [0]=> object(SimpleXMLElement)#4 (0) { } } } -- Edit bug report at https://bugs.php.net/bug.php?id=66084&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66084&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66084&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66084&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66084&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66084&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66084&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66084&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66084&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66084&r=support Expected behavior: https://bugs.php.net/fix.php?id=66084&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66084&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66084&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66084&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66084&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66084&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66084&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66084&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66084&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66084&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66084&r=mysqlcfg

« previous php.bugs (#182720) next »