mmraja83 / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Duplicate CDATA in XHTML #278

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Are you sure this is not a problem with your configuration? (ask on the
Google Group)

Minify commit/version: 2.1.5
PHP version: 5.2

What steps will reproduce the problem?
1. Try to minify XHTML already containing scripts with CDATA:
<script><![CDATA[ alert("&"); ]]> </script>

Expected output:
<script>/*<![CDATA[*/ alert("&"); /*]]>/* </script>

Actual output:
CDATA is attached twice.

My fix to the problem:
minify-2.1.5\min\lib\Minify\HTML.php, line 244.
Replace line:
return ($this->_isXhtml && preg_match('/(?:[<&]|\\-\\-|\\]\\]>)/', $str));
With: 
return ($this->_isXhtml && preg_match('/(?:[<&]|\\-\\-|\\]\\]>)/', $str) && 
!preg_match('#\<\!\[CDATA#ui', $str));

Original issue reported on code.google.com by moroz1...@gmail.com on 11 Oct 2012 at 11:03

GoogleCodeExporter commented 9 years ago
Thanks for the report. Will check this out.

Original comment by mrclay....@gmail.com on 11 Oct 2012 at 6:20

GoogleCodeExporter commented 9 years ago

Original comment by mrclay....@gmail.com on 11 Oct 2012 at 6:21