jsmin-php icon indicating copy to clipboard operation
jsmin-php copied to clipboard

javascript variable that starts with '$' parsed incorrectly

Open scramatte opened this issue 15 years ago • 4 comments

Hello,

If you have javascript variable that starts with '$' jsmin-php parse it incorrectly resulting in javascript error. In mootools/mif tree project (http://github.com/creaven/miftree) the author use this.$ = {} or this.$index = null. Jsmin-php is unable to recognize this syntax.

scramatte avatar Jan 25 '10 15:01 scramatte

Same problem here.

digggggggggg avatar Feb 09 '10 16:02 digggggggggg

Nobody for a patch to correct this issue ?

kerphi avatar Jun 20 '11 10:06 kerphi

I saw a patch for this at some point but lost it. I'm terrible at regexes but I think the problem is in the isAlphaNum function.

Below is what the function looks like in the current master:

  protected function isAlphaNum($c) {
    return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1;

Krinkle avatar Oct 17 '11 08:10 Krinkle

I added the mif.tree library (1.2.6.4 as of this writing) as a test case in my fork on js-min-php and it passes against the C version of jsmin. The output from my fork doesn't exhibit a JS error, possibly an outdated bug?

https://github.com/jaydiablo/jsmin-php

jaydiablo avatar Jul 03 '12 23:07 jaydiablo