diff options
author | Andreas Gohr <andi@splitbrain.org> | 2006-05-27 16:01:57 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2006-05-27 16:01:57 +0200 |
commit | 45be45c58fffce1b3e57942130b69600cc426457 (patch) | |
tree | 10300a9ec0c0b0d542746407b40d33eaf31b6cef /lib | |
parent | 44409c3dd2fce9ef930e0e23d47f1a46e5bc7d1a (diff) | |
download | rpg-45be45c58fffce1b3e57942130b69600cc426457.tar.gz rpg-45be45c58fffce1b3e57942130b69600cc426457.tar.bz2 |
small improvements on JS compressor (maybe fixes #807)
darcs-hash:20060527140157-7ad00-225a9ba66f658cc279cb44ebb04d483291d567d2.gz
Diffstat (limited to 'lib')
-rw-r--r-- | lib/exe/js.php | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/exe/js.php b/lib/exe/js.php index 7ff60710c..2aa9c4399 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -238,7 +238,7 @@ function js_compress($s){ $len = strlen($s); // items that don't need spaces next to them - $chars = '^&|!+\-*\/%=:;,{}()<>% \t\n\r'; + $chars = '^&|!+\-*\/%=\?:;,{}()<>% \t\n\r'; ob_start(); while($i < $len){ @@ -286,11 +286,12 @@ function js_compress($s){ // double quote strings if($ch == '"'){ $j = 1; - while( $s{$i+$j} != '"' ){ - while( ($s{$i+$j} != '\\') && ($s{$i+$j} != '"') ){ - $j = $j + 1; + while( $s{$i+$j} != '"' && ($i+$j < $len)){ + if( $s{$i+$j} == '\\' && $s{$i+$j+1} == '"' ){ + $j += 2; + }else{ + $j += 1; } - if($s{$i+$j} == '\\') $j = $j + 2; } echo substr($s,$i,$j+1); $i = $i + $j + 1; @@ -300,11 +301,12 @@ function js_compress($s){ // single quote strings if($ch == "'"){ $j = 1; - while( $s{$i+$j} != "'" ){ - while( ($s{$i+$j} != '\\') && ($s{$i+$j} != "'") ){ - $j = $j + 1; + while( $s{$i+$j} != "'" && ($i+$j < $len)){ + if( $s{$i+$j} == '\\' && $s{$i+$j+1} == "'" ){ + $j += 2; + }else{ + $j += 1; } - if ($s{$i+$j} == '\\') $j = $j + 2; } echo substr($s,$i,$j+1); $i = $i + $j + 1; |