From:             ed at avi dot ru
Operating system: Windows 98
PHP version:      4.3.0
PHP Bug Type:     DOM XML related
Bug description:  Incorrect CDATA output by DomDocument::dump_mem()

When we put some XML markup in CDATA section of dom_xml's DomDocument,
everything goes OK. But when that markup contains CDATA section ITSELF,
the output is invalid due to the unescaped ']]>' sequence in CDATA
section. Here's the code:

<?PHP

        $doc = domxml_new_doc ('1.0');
        $root = $doc->append_child ($doc->create_element ('root'));

        $cdata_1 = $root->append_child ($doc->create_element ('cdata-1'));
        $cdata_1->append_child ($doc->create_cdata_section ('Some generic
text'));

        print ('<PRE>');

        print ("Test 1. Everything's ok.\n\n");
        print (htmlspecialchars ($doc->dump_mem (TRUE, 'UTF-8')));

        $cdata_1->unlink_node ();

        $cdata_2 = $root->append_child ($doc->create_element ('cdata-2'));
        $cdata_2->append_child ($doc->create_cdata_section ('<?xml
version="1.0"?><root><![CDATA[Some XML with CDATA]]></root>'));

        print ("\n\nTest 2. The ]]&gt; symbol sequence in CDATA is not
escaped.\n\n");
        print (htmlspecialchars ($doc->dump_mem (TRUE, 'UTF-8')));

        print ('</PRE>');

?>


-- 
Edit bug report at http://bugs.php.net/?id=22589&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=22589&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=22589&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=22589&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=22589&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=22589&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=22589&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=22589&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=22589&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=22589&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=22589&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22589&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=22589&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=22589&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=22589&r=gnused

Reply via email to