From:             milman at gmx dot de
Operating system: WindowsXP
PHP version:      5.1.4
PHP Bug Type:     SimpleXML related
Bug description:  different by attribute-assignment if new attribute or old 
attribute

Description:
------------
if you make an assignmet to an attribute and the value you assign has
special chars, it makes a difference if the attribute is new or not.

the best way would be if there was no need for the htmlspecialchars
function call.

Reproduce code:
---------------
<?php
echo "<body>\n" ;

error_reporting(E_ALL | E_STRICT) ;

$xml = simplexml_load_string('<xml></xml>');

$str = "abc & def" ;

$xml["a1"] = "" ;
$xml["a1"] = htmlspecialchars($str,ENT_NOQUOTES) ;

$xml["a2"] = htmlspecialchars($str,ENT_NOQUOTES) ;

$xml["a3"] = "" ;
$xml["a3"] = $str ;

$xml["a4"] = $str ;

echo "<xmp>\n" ;
echo "str: $str \n" ;
echo "a1: correct: {$xml["a1"]} \n" ;
echo "a2: wrong:   {$xml["a2"]} \n" ;
echo "a3: wrong:   {$xml["a3"]} \n" ;
echo "a4: correct: {$xml["a4"]} \n" ;
echo $xml->asXML() ;
echo "</xmp>\n" ;
echo "</body>\n" ;
?>


-- 
Edit bug report at http://bugs.php.net/?id=38424&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38424&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38424&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38424&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=38424&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=38424&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=38424&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=38424&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=38424&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=38424&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=38424&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=38424&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=38424&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=38424&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38424&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=38424&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=38424&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=38424&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38424&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=38424&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=38424&r=mysqlcfg

Reply via email to