Bug #75245 [PATCH]: simplexml_load_string() fails to parse an element filled only with spaces
| From: | erik@coretech.se | Date: | Tue, 13 Aug 2019 20:59:26 +0000 |
| Subject: | Bug #75245 [PATCH]: simplexml_load_string() fails to parse an element filled only with spaces | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-222241@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75245&edit=1
ID: 75245
Patch added by: erik@coretech.se
Reported by: lkppo at free dot fr
Summary: simplexml_load_string() fails to parse an element
filled only with spaces
Status: Open
Type: Bug
Package: SimpleXML related
Operating System: Debian 9
PHP Version: 7.0Git-2017-09-22 (Git)
Block user comment: N
Private report: N
New Comment:
The following pull request has been associated:
Patch Name: Fix #75245: Don't set content of elements with only whitespaces
On GitHub: https://github.com/php/php-src/pull/4533
Patch: https://github.com/php/php-src/pull/4533.patch
Previous Comments:
------------------------------------------------------------------------
[2017-09-22 11:54:43] lkppo at free dot fr
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 this bug report at https://bugs.php.net/bug.php?id=75245&edit=1