rgrove / jsmin

:skull: Ruby library for minifying JavaScript. Based on Douglas Crockford's jsmin.c. Unmaintained.
51 stars 4 forks source link

JSMin does not properly handle escaped newlines inside literal strings #3

Open tmorton opened 12 years ago

tmorton commented 12 years ago

JSMin will fail with an "JSMin parse error: unterminated string literal" error on this type of code:

var a = 'stuff \
more stuff';

I believe the problem is with the check on lines 157-159. In Crockford's C version, latest master, that check is not there - see https://github.com/douglascrockford/JSMin/blob/master/jsmin.c

tmorton commented 12 years ago

In case anyone was wondering if that JS code is valid, see https://developer.mozilla.org/en/JavaScript/Guide/Values,_Variables,_and_Literals#Using_special_characters_in_strings

rgrove commented 12 years ago

Thanks for the report. If jsmin.c handles this and jsmin.rb doesn't, then this is definitely a bug. I don't use or actively maintain this code anymore though, so: pull requests welcome!