Bug #68946 [Opn]: simplexml_load_string() result depends on formatting of xml string

From: Date: Thu, 29 Jan 2015 15:35:24 +0000
Subject: Bug #68946 [Opn]: simplexml_load_string() result depends on formatting of xml string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190308@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68946&edit=1

 ID:                 68946
 User updated by:    danielhintermann at yahoo dot de
 Reported by:        danielhintermann at yahoo dot de
 Summary:            simplexml_load_string() result depends on formatting
                     of xml string
 Status:             Open
 Type:               Bug
 Package:            SimpleXML related
 Operating System:   Windows
 PHP Version:        5.6.5
 Block user comment: N
 Private report:     N

 New Comment:

Could be a duplicate of #68507.


Previous Comments:
------------------------------------------------------------------------
[2015-01-29 15:29:03] danielhintermann at yahoo dot de

Description:
------------
First, the bug could also be triggered on PHP version 5.3.28 on windows.
Secondly, it could be related to the issue Bug #61335.

Depending on formatting of a xml string the comparing with '== false' gives different
result. It is clear that the === operator should be used, however, the == operator still should give
consistent results!

Test script:
---------------
<?php

class TestComparisonOperator extends PHPUnit_Framework_TestCase {
    public function testWithoutSpaceFormat() {
        $oXml = simplexml_load_string($this->getXmlNoFormatting());

        var_dump($oXml);

        $this->assertFalse($oXml == false);
   }

    public function testWithSpaceFormat() {
        $oXml = simplexml_load_string($this->getXmlWithSpaceFormat());

        var_dump($oXml);

        $this->assertFalse($oXml == false);
    }

    private function getXmlNoFormatting()
    {
        return "<?BrightCloud
version=bcap/1.1?><bcap><seqnum>1</seqnum></bcap>";
    }

    private function getXmlWithSpaceFormat()
    {
        // look at the space after bcap tag!
        return "<?BrightCloud version=bcap/1.1?><bcap>
<seqnum>1</seqnum></bcap>";
    }
}




------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=68946&edit=1


Thread (7 messages)

« previous php.bugs (#190308) next »