gaurav-spacreo / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

JSMin Unterminated Regular expression in an aritmatic expression #222

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Minify version: current trunk
PHP version: 5.3.5

What steps will reproduce the problem?
1. Run the attached file through JSMin

Expected output:
minified file

Actual output:
Exception error "Unterminated regular expression"

I also tried the 2.1.3 Tag version as well as the 2.1.4 branch.
Ad this issue also (sometimes) occurs with the original jsmin.c

If I move th

Original issue reported on code.google.com by urkle0 on 20 Feb 2011 at 8:16

Attachments:

GoogleCodeExporter commented 9 years ago
JSMin, not being a real parser, has a tough time distinguishing between 
division and the beginning of a regexp literal, and after a line break the 
original algorithm has always assumed that "/" would start a regexp. Maybe this 
assumption needs some testing?

Open 
http://code.google.com/p/minify/source/browse/branches/2.1.4/min/lib/JSMin.php 
and try changing this:

        if (false !== strpos("\n{;(,=:[!&|?", $this->a)) { // we aren't dividing
            return true;
        }

to:

        if ($this->a === "\n") {
            return false; /* assume division */
        }
        if (false !== strpos("{;(,=:[!&|?", $this->a)) { // we aren't dividing
            return true;
        }

I'd need to see a lot of testing before I'd release such a change though.

Original comment by mrclay....@gmail.com on 21 Feb 2011 at 3:23