Invalid semicolon causes infinite loop #29

Closed
rcadena opened this Issue Apr 6, 2012 · 4 comments

Projects

None yet

2 participants

@rcadena
rcadena commented Apr 6, 2012

slimit version = 0.6

Try the following code:

from slimit import minify

src = """var a = 1;
, b = 2;"""
minify(src)

On my machine (os x 10.7.3, python 2.7, slimit 0.6) the function doesn't return and it hogs all the cpu. I know it's invalid JS, but no error is reported by minify, it just doesn't return.

If you remove the "," before "b = 2" then it returns with the result.

In fact, you can get it to get stuck on simpler code:

src = """var a;
, b;"""

minify(src)

The above code shows the same problem as the first code.

If you put both on the same line:

src = """var a; , b;"""

It returns with a Syntax Error: "Unexpected token (COMMA, ',') blah blah"

@rspivak
Owner
rspivak commented Apr 7, 2012

Thanks a lot for the detailed report. Looks like a parser gets stuck in a loop.

@rspivak
Owner
rspivak commented Apr 7, 2012

Fixed in 3d8d5f3

@rspivak rspivak closed this Apr 7, 2012
@rspivak
Owner
rspivak commented Apr 7, 2012

I've uploaded a new version of Slimit 0.6.2 to PyPI so you can just pip install -U slimit to test it

@rcadena
rcadena commented Apr 9, 2012

awesome. will test. thanks

@acatton acatton added a commit to acatton/slimit that referenced this issue Jan 26, 2015
@rspivak Bug fix - rspivak#29 2d9a65c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment