Bug #75245 [Opn->Csd]: simplexml_load_string() fails to parse an element filled only with spaces

From: Date: Wed, 02 Oct 2019 06:17:54 +0000
Subject: Bug #75245 [Opn->Csd]: 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-222983@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
 Updated by:         krakjoe@php.net
 Reported by:        lkppo at free dot fr
 Summary:            simplexml_load_string() fails to parse an element
                     filled only with spaces
-Status:             Open
+Status:             Closed
 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:

Automatic comment on behalf of erik@coretech.se
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6462c196897b8c5ccf606b8af8de790b77799de6
Log: Fixed #75245 Don't set content of elements with only whitespaces


Previous Comments:
------------------------------------------------------------------------
[2019-08-13 20:59:26] erik at coretech dot se

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

------------------------------------------------------------------------
[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


Thread (3 messages)

« previous php.bugs (#222983) next »