From: dandrikop at cosmote dot gr
Operating system: Fedora Core 5
PHP version: 5.1.5
PHP Bug Type: DOM XML related
Bug description: DOM Function saveXML
Description:
------------
I use the new DOM extension of PHP5. I want to pass special characters
manually in the XML CDATA tags, but special characters such as '&' are
automatically escaped.
Reproduce code:
---------------
<?php
$imp = new DOMImplementation();
$dtd = $imp->createDocumentType( 'clickAPI', null, 'xml_dtd.txt'
);
$xml_request = $imp->createDocument( null, null, $dtd );
$xml_request->version = '1.0';
$xml_request->formatOutput = true;
// Create the tag 'clickAPI'.
$clickAPI = $xml_request->appendChild( new DOMElement( 'clickAPI'
) );
// Create the tag 'sendMsg'.
$sendMsg = $clickAPI->appendChild( new DOMElement( 'sendMsg' )
);
// Add elements under the 'auth' tag.
$sendMsg->appendChild( new DOMElement( 'session_id',
'aaaaaaaaaaaaaaaaa' ) );
// $sendMsg->appendChild( new DOMElement( 'text', "Test " )
);
$text = $sendMsg->appendChild( new DOMElement( 'text' ) );
$text->appendChild( new DOMText( "Test " ) );
$sendMsg->appendChild( new DOMElement( 'to', '306978888888' )
);
if( @$xml_request->validate() ){
echo "OK\n";
} else {
echo "Not OK!\n";
}
echo "\n" . $xml_request->saveXML() . "\n";
?>
Expected result:
----------------
OK
<?xml version="1.0"?>
<!DOCTYPE clickAPI SYSTEM "xml_dtd.txt">
<clickAPI>
<sendMsg>
<session_id>aaaaaaaaaaaaaaaaa</session_id>
<text>Test </text>
<to>306978888888</to>
</sendMsg>
</clickAPI>
Actual result:
--------------
OK
<?xml version="1.0"?>
<!DOCTYPE clickAPI SYSTEM "xml_dtd.txt">
<clickAPI>
<sendMsg>
<session_id>aaaaaaaaaaaaaaaaa</session_id>
<text>Test &#10;</text>
<to>306978888888</to>
</sendMsg>
</clickAPI>
--
Edit bug report at http://bugs.php.net/?id=38562&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=38562&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=38562&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=38562&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38562&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=38562&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38562&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38562&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38562&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38562&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38562&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=38562&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=38562&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38562&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38562&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38562&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38562&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38562&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38562&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38562&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38562&r=mysqlcfg