From: daine dot mamacos at complinet dot com Operating system: Linux 2.4.21-4.ELsmp PHP version: 5.0.3 PHP Bug Type: DOM XML related Bug description: formatOutput breaks cdata section nodes
Description: ------------ If you create an element on a DOMDocument, and then append a CDATA section to the node, if formatOutput is enabled, it makes the node put a return caridge before and after the CDATA section. IE: <key_0> <![CDATA[BLAHBLAH]]> </key_0> This is problematic, as when you fetch the data from the node, it carries the return caridges with it. The only way of solving this currently (that I know of) is to not use formattput on the DOMDocument. Reproduce code: --------------- <?php $dom = new DOMDocument("1.0"); $dom->formatOutput = true; $node = $dom->createElement("node"); $cdata = $dom->createCDATASection("BLAH BLAH BLAH"); $dom->appendChild($node); $node->appendChild($cdata); $dom2 = DOMDocument::loadXML($dom->saveXML()); $rootNode = $dom2->documentElement; $text = $rootNode->textContent; print("'$text'"); $packData = @unpack("H*", $text); print_r($packData); ?> Expected result: ---------------- 'BLAH BLAH BLAH'Array ( [1] => 424c414820424c414820424c4148 ) Actual result: -------------- ' BLAH BLAH BLAH 'Array ( [1] => 0a424c414820424c414820424c41480a ) //you can see the 0A after the ' and before the closing ' -- Edit bug report at http://bugs.php.net/?id=32998&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32998&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32998&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32998&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=32998&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=32998&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=32998&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=32998&r=needscript Try newer version: http://bugs.php.net/fix.php?id=32998&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=32998&r=support Expected behavior: http://bugs.php.net/fix.php?id=32998&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=32998&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=32998&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=32998&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32998&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=32998&r=dst IIS Stability: http://bugs.php.net/fix.php?id=32998&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=32998&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=32998&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=32998&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=32998&r=mysqlcfg