ndparker / rjsmin

Fast javascript minifier for Python
http://opensource.perlig.de/rjsmin/
Apache License 2.0
60 stars 15 forks source link

minify easymde-2.14.min.js causes error on regular expression #23

Closed BoPeng closed 2 years ago

BoPeng commented 3 years ago

easymde.min.txt easymde.min1.txt

Steps to reproduce:

  1. Download https://unpkg.com/easymde/dist/easymde.min.js
  2. Run python -mrjsmin < easymde.min.js > easymde.min1.js
  3. Use easymde.min1.js instead of easymde.min.js, chrome does not complain, firefox raises an error
Uncaught SyntaxError: nothing to repeat,  easymde.min1.js:1:229168

Checking the location, the difference is the removal of two spaces in a regular expression, which looks wrong to me

{var r,i=n.align.length;for(r=0;r<i;r++)/^ *-+: *$/.test(n.align[r])?n.align[r]="right":/^ *:-+: *$/.
{var r,i=n.align.length;for(r=0;r<i;r++)/^*-+:*$/.test(n.align[r])?n.align[r]="right":/^ *:-+: *$/.

Note that I was minifying a min.js file because it was concatenated with some other js files to be minified together.

ndparker commented 3 years ago

Hi,

regexes in JS are a syntactical disaster :-(

Duplicate of #17

ndparker commented 2 years ago

Fixed in 1.2.0