Bug #75245 [NEW]: simplexml_load_string() fails to parse an element filled only with spaces

From: Date: Fri, 22 Sep 2017 11:54:47 +0000
Subject: Bug #75245 [NEW]: simplexml_load_string() fails to parse an element filled only with spaces
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211322@lists.php.net to get a copy of this message
From: lkppo at free dot fr Operating system: Debian 9 PHP version: 7.0Git-2017-09-22 (Git) Package: SimpleXML related Bug Type: Bug Bug description:simplexml_load_string() fails to parse an element filled only with spaces Description: ------------ When I parses a validating XML with simplexml_load_string(), and this XML have an element filled only with spaces, the parser find an array of string instead of a string. Test script: --------------- $xmlpost = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <results> <row> <firstname>THIERRY</firstname> <address1> </address1> <address2/> </row> </results> '; $xml = simplexml_load_string($xmlpost); echo '<pre>'; var_dump($xml); echo '</pre>'; Expected result: ---------------- object(SimpleXMLElement)#1 (1) { ["row"]=> object(SimpleXMLElement)#2 (3) { ["firstname"]=> string(7) "THIERRY" ["address1"]=> string(3) " " ["address2"]=> object(SimpleXMLElement)#3 (0) { } } } Actual result: -------------- object(SimpleXMLElement)#1 (1) { ["row"]=> object(SimpleXMLElement)#2 (3) { ["firstname"]=> string(7) "THIERRY" ["address1"]=> object(SimpleXMLElement)#3 (1) { [0]=> string(3) " " } ["address2"]=> object(SimpleXMLElement)#4 (0) { } } } -- Edit bug report at https://bugs.php.net/bug.php?id=75245&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75245&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75245&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75245&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75245&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75245&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75245&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75245&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75245&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75245&r=support Expected behavior: https://bugs.php.net/fix.php?id=75245&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75245&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75245&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75245&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75245&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75245&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75245&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75245&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75245&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75245&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75245&r=mysqlcfg

« previous php.bugs (#211322) next »