summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2006-08-01 00:30:08 +0200
committerAndreas Gohr <andi@splitbrain.org>2006-08-01 00:30:08 +0200
commite5cafda07c413096a4acbd71c4b4fbf34054a093 (patch)
treef6fe0baf262e3648bf1caf9b52d13bbd682f386b
parent0d35318916bc5b232dfc3532db0efb26f0af7f22 (diff)
downloadrpg-e5cafda07c413096a4acbd71c4b4fbf34054a093.tar.gz
rpg-e5cafda07c413096a4acbd71c4b4fbf34054a093.tar.bz2
fix in JS compressor
This fixes a problem with escaped backslashes in single and double quote strings. darcs-hash:20060731223008-7ad00-ebae61a00115b7f32c12eb9355059a1ecf467cd3.gz
-rw-r--r--_test/cases/lib/exe/js_js_compress.test.php5
-rw-r--r--lib/exe/js.php4
2 files changed, 7 insertions, 2 deletions
diff --git a/_test/cases/lib/exe/js_js_compress.test.php b/_test/cases/lib/exe/js_js_compress.test.php
index f46cbe227..20ad88210 100644
--- a/_test/cases/lib/exe/js_js_compress.test.php
+++ b/_test/cases/lib/exe/js_js_compress.test.php
@@ -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
diff --git a/lib/exe/js.php b/lib/exe/js.php
index 9854f1b45..e01ab7bf5 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -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;