Skip to content
Snippets Groups Projects
Commit e5cafda0 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

fix in JS compressor

This fixes a problem with escaped backslashes in single and double quote
strings.

darcs-hash:20060731223008-7ad00-ebae61a00115b7f32c12eb9355059a1ecf467cd3.gz
parent 0d353189
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,11 @@ class js_js_compress_test extends UnitTestCase {
$this->assertEqual(js_compress($text), $text);
}
function test_dquot2(){
$text = 'var foo="Now what \\\\\\" \'do we//get /*here*/ ?";';
$this->assertEqual(js_compress($text), $text);
}
function test_dquotrunaway(){
$text = 'var foo="Now where does it end';
$this->assertEqual(js_compress($text), "$text\n"); //\n is added by compressor
......
......@@ -290,7 +290,7 @@ function js_compress($s){
if($ch == '"'){
$j = 1;
while( $s{$i+$j} != '"' && ($i+$j < $len)){
if( $s{$i+$j} == '\\' && $s{$i+$j+1} == '"' ){
if( $s{$i+$j} == '\\' && ($s{$i+$j+1} == '"' || $s{$i+$j+1} == '\\') ){
$j += 2;
}else{
$j += 1;
......@@ -305,7 +305,7 @@ function js_compress($s){
if($ch == "'"){
$j = 1;
while( $s{$i+$j} != "'" && ($i+$j < $len)){
if( $s{$i+$j} == '\\' && $s{$i+$j+1} == "'" ){
if( $s{$i+$j} == '\\' && ($s{$i+$j+1} == "'" || $s{$i+$j+1} == '\\') ){
$j += 2;
}else{
$j += 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment