@@ -623,6 +623,30 @@ QUnit.test('collapsing space in conditional comments', function(assert) {
623623  } ) ,  output ) ; 
624624} ) ; 
625625
626+ QUnit . test ( '(bug) CDATA parsed as conditional comments' ,  function ( assert )  { 
627+   var  input ; 
628+ 
629+   input  =  '<![CDATA[line 1\nline 2]]>' ; 
630+   assert . equal ( minify ( input ) ,  input ) ; 
631+   assert . equal ( minify ( input ,  {  removeComments : true  } ) ,  '' ) ; 
632+   input  =  '<p><![CDATA[line 1\nline 2]]></p>' ; 
633+   assert . equal ( minify ( input ) ,  input ) ; 
634+   assert . equal ( minify ( input ,  {  removeComments : true  } ) ,  '<p></p>' ) ; 
635+ 
636+   input  =  '<![CDATA[]]>' ; 
637+   assert . equal ( minify ( input ) ,  input ) ; 
638+   assert . equal ( minify ( input ,  {  removeComments : true  } ) ,  '' ) ; 
639+ 
640+   // https://github.com/kangax/html-minifier/issues/1161 
641+   input  =  '<![CDATA[___]><-___]]>' ; 
642+   assert . throws ( function ( )  { 
643+     minify ( input ) ; 
644+   } ,  '"]>" treated as end instead of "]]>" (bug)' ) ; 
645+   assert . throws ( function ( )  { 
646+     minify ( input ,  {  removeComments : true  } ) ; 
647+   } ,  '"]>" treated as end instead of "]]>" (bug)' ) ; 
648+ } ) ; 
649+ 
626650QUnit . test ( 'remove comments from scripts' ,  function ( assert )  { 
627651  var  input ,  output ; 
628652
0 commit comments