Bug #54429 [Opn->Sus]: domDocument::loadHTML adds extra CDATA tags causing script errors.

From: Date: Thu, 31 Mar 2011 04:27:47 +0000
Subject: Bug #54429 [Opn->Sus]: domDocument::loadHTML adds extra CDATA tags causing script errors.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-159867@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=54429&edit=1 ID: 54429 Updated by: rasmus@php.net Reported by: ken at smallboxcms dot com Summary: domDocument::loadHTML adds extra CDATA tags causing script errors. -Status: Open +Status: Suspended Type: Bug Package: DOM XML related Operating System: Centos 5.5 PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: You would need to file this against the libxml2 library as this isn't something we can fix at the PHP level. See http://xmlsoft.org/bugs.html Previous Comments: ------------------------------------------------------------------------ [2011-03-31 06:23:32] ken at smallboxcms dot com Description: ------------ This one has annoyed me for a long time. When you load HTML useing loadHTML you get extra CDATA tags on the script tags causing browser errors. This does not happen when loadXML is used. Test script: --------------- <?php $foo = ' <html> <head> <title></title> </head> <body> <script type="text/javascript"> //<![CDATA[ alert("foo bar"); //]]> </script> </body> </html> '; $dom = new domDocument('1,0', 'utf-8'); $dom->loadHTML($foo); echo $dom->saveXML(); ?> Expected result: ---------------- <?xml version="1.0" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><head><title/></head><body> <script type="text/javascript"> //<![CDATA[ alert("foo bar"); //]]> </script></body></html> Actual result: -------------- <?xml version="1.0" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><head><title/></head><body> <script type="text/javascript"><![CDATA[ //<![CDATA[ alert("foo bar"); //]]]]><![CDATA[> ]]></script></body></html> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54429&edit=1

« previous php.bugs (#159867) next »