alexo / wro4j

New project location is:https://github.com/wro4j/wro4j
442 stars 110 forks source link

Port JSMin fix to handle slash inside square brackets in regex. #151

Closed olim7t closed 11 years ago

olim7t commented 11 years ago

The JSMin bundled in Wro4J fails on regexes like /[/']/. The second / is mistakenly intepreted as the end of the regex.

This bug was fixed on the original C implementation (douglascrockford/JSMin@55809e6d07be4a0d3029d48112d16ef833e55cf7); this is a simple port of the changes.

I ran into the bug while trying to minify chjj/marked.

alexo commented 11 years ago

@olim7t Unfortunately, the following test case still fails:

return /\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s);
olim7t commented 11 years ago

Escaping a slash inside square brackets is not required but seems to be allowed.

The C version of JSMin handles that correctly, so it must be fixed by another commit. I'll try to look into it.

alexo commented 11 years ago

@olim7t could you commit to branch called issue660 ? It already contains your pull request. I usually merge into stable 1.7.x every feature branch after its development is completed.