summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2011-06-05 13:15:56 +0200
committerAndreas Gohr <andi@splitbrain.org>2011-06-05 13:15:56 +0200
commit6992ea08420671362032b795cd2972cfc0ef5f01 (patch)
treecdfb571369de777fffa7dbe35bed4f10ef18b2d1
parent303d4f1470333e1ba613083310ab52b886f3d68c (diff)
downloadrpg-6992ea08420671362032b795cd2972cfc0ef5f01.tar.gz
rpg-6992ea08420671362032b795cd2972cfc0ef5f01.tar.bz2
fixed JavaScript compressor for certain regexes
This fixes a problem with running the minified jQuery through the compressor.
-rw-r--r--_test/cases/lib/exe/js_js_compress.test.php6
-rw-r--r--lib/exe/js.php2
2 files changed, 7 insertions, 1 deletions
diff --git a/_test/cases/lib/exe/js_js_compress.test.php b/_test/cases/lib/exe/js_js_compress.test.php
index 76b51e5ab..4702d35d3 100644
--- a/_test/cases/lib/exe/js_js_compress.test.php
+++ b/_test/cases/lib/exe/js_js_compress.test.php
@@ -105,6 +105,12 @@ class js_js_compress_test extends UnitTestCase {
}
+ function test_complexminified(){
+ $text = 'if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="<div class=\'test e\'></div><div class=\'test\'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;foo="text/*";bla="*/"';
+
+ $this->assertEqual(js_compress($text),$text);
+ }
+
/**
* Test the files provided with the original JsStrip
*/
diff --git a/lib/exe/js.php b/lib/exe/js.php
index b0618dc4c..e4c5c2ab8 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -294,7 +294,7 @@ function js_compress($s){
// items that don't need spaces next to them
$chars = "^&|!+\-*\/%=\?:;,{}()<>% \t\n\r'\"[]";
- $regex_starters = array("(", "=", "[", "," , ":");
+ $regex_starters = array("(", "=", "[", "," , ":", "!");
$whitespaces_chars = array(" ", "\t", "\n", "\r", "\0", "\x0B");