From ef457c67624460b5703178e7b11edc2f9fffda01 Mon Sep 17 00:00:00 2001 From: Pierre Paysant-Le Roux Date: Thu, 5 Nov 2009 22:34:52 +0100 Subject: Fix js_compress regexp detection Ignore-this: ffb20375a09483502d61241d76877a8d darcs-hash:20091105213452-533a7-f09aca121cf24a8b6ad2d3448d058a846cb52182.gz --- lib/exe/js.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/exe/js.php b/lib/exe/js.php index 0888fa57f..ab67288cd 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -282,6 +282,10 @@ function js_compress($s){ // items that don't need spaces next to them $chars = "^&|!+\-*\/%=\?:;,{}()<>% \t\n\r'\"[]"; + $regex_starters = array("(", "=", "[", "," , ":"); + + $whitespaces_chars = array(" ", "\t", "\n", "\r", "\0", "\x0B"); + while($i < $slen){ // skip all "boring" characters. This is either // reserved word (e.g. "for", "else", "if") or a @@ -312,10 +316,10 @@ function js_compress($s){ if($ch == '/'){ // rewind, skip white space $j = 1; - while($s{$i-$j} == ' '){ + while(in_array($s{$i-$j}, $whitespaces_chars)){ $j = $j + 1; } - if( ($s{$i-$j} == '=') || ($s{$i-$j} == '(') ){ + if( in_array($s{$i-$j}, $regex_starters) ){ // yes, this is an re // now move forward and find the end of it $j = 1; -- cgit v1.2.3