cvs: pear /XML_Util Util.php /XML_Util/tests testBug_4950.phpt

[email protected] ("Chuck Burgess") Sun, 04 May 2008 22:24:18 -0000
Newsgroups php.pear.cvs
Message-ID <cvsashnazg1209939858@cvsserver>
ashnazg		Sun May  4 22:24:18 2008 UTC

  Modified files:              
    /pear/XML_Util	Util.php 
    /pear/XML_Util/tests	testBug_4950.phpt 
  Log:
  fix Bug #4950: Incorrect CDATA serializing
  
http://cvs.php.net/viewvc.cgi/pear/XML_Util/Util.php?r1=1.30&r2=1.31&diff_format=u
Index: pear/XML_Util/Util.php
diff -u pear/XML_Util/Util.php:1.30 pear/XML_Util/Util.php:1.31
--- pear/XML_Util/Util.php:1.30	Sun May  4 15:17:51 2008
+++ pear/XML_Util/Util.php	Sun May  4 22:24:17 2008
@@ -671,7 +671,8 @@
     */
     function createCDataSection($data)
     {
-        return  sprintf("<![CDATA[%s]]>", $data);
+        return sprintf("<![CDATA[%s]]>", 
+            preg_replace('/\]\]>/', "]]>]]&gt;<![CDATA[", strval($data)));
     }
 
    /**
http://cvs.php.net/viewvc.cgi/pear/XML_Util/tests/testBug_4950.phpt?r1=1.1&r2=1.2&diff_format=u
Index: pear/XML_Util/tests/testBug_4950.phpt
diff -u pear/XML_Util/tests/testBug_4950.phpt:1.1 pear/XML_Util/tests/testBug_4950.phpt:1.2
--- pear/XML_Util/tests/testBug_4950.phpt:1.1	Sun May  4 18:34:58 2008
+++ pear/XML_Util/tests/testBug_4950.phpt	Sun May  4 22:24:18 2008
@@ -11,4 +11,4 @@
 ?>
 --EXPECT--
 TEST:  test case provided in bug report
-<test><![CDATA[Content ]]>]]><![CDATA[</test> here!]]></test>
+<test><![CDATA[Content ]]>]]&gt;<![CDATA[</test> here!]]></test>