ndparker / rjsmin

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

Output truncated at // within a string literal in already minified input #28

Open ercpe opened 1 year ago

ercpe commented 1 year ago

We're using rjsmin through django-compressor and noticed that the output is truncated at // within a string literal in an already minified input.

The input is the Sentry JS SDK browser bundle, e.g. https://browser.sentry-cdn.com/7.60.0/bundle.min.js In this case, we run multiple sentry-related files through django-compressor to create a single bundle, not to actually minify the files.

When run through rjsmin, the output is truncated:

$  python -m rjsmin < ~/Downloads/browser.sentry-cdn.com_7.60.0_bundle.min.js

...{if(!("fetch"in J))return!1;try{return new Headers,new Request("http:

The occurence in the input file is:

try{return new Headers,new Request("http://www.example.com"),new Response,!0}catch(t){return!1}}
ndparker commented 11 months ago

Hi, I finally had time to look at it, sorry for the delay. There's a nested template string occuring before, which contains double quotes:

return`${c}://${u}${n&&i?`:${i}`:""}@${e}${s?`:${s}`:""}/${r?`${r}/`:r}${o}`

This is where it runs out of sync. Unfortunately rjsmin does not support template strings properly at the moment :-(