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

From: Date: Thu, 29 Jan 2015 15:29:03 +0000
Subject: Bug #68946 [NEW]: simplexml_load_string() result depends on formatting of xml string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190307@lists.php.net to get a copy of this message
From:             danielhintermann at yahoo dot de
Operating system: Windows
PHP version:      5.6.5
Package:          SimpleXML related
Bug Type:         Bug
Bug description:simplexml_load_string() result depends on formatting of xml string

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 bug report at https://bugs.php.net/bug.php?id=68946&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=68946&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=68946&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=68946&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=68946&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=68946&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=68946&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=68946&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=68946&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=68946&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=68946&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=68946&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=68946&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=68946&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68946&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=68946&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=68946&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=68946&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68946&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=68946&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=68946&r=mysqlcfg



Thread (7 messages)

« previous php.bugs (#190307) next »