Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with strings values minification #20

Open
RChutchev opened this issue Oct 12, 2024 · 5 comments
Open

Bug with strings values minification #20

RChutchev opened this issue Oct 12, 2024 · 5 comments

Comments

@RChutchev
Copy link

RChutchev commented Oct 12, 2024

Hi, we discovered a problem with minification.
We've string like "Hello (or hi), world" in

tag, and after minification output looks like "Hello (or hi),world".
Looks like that's a bug and I can't fix that by adding an extra exclude regex in config, I can exclude routes only.

I think this one regex causes this.
//remove new-line after JS's line end (only most obvious and safe cases)
'/),[\r\n\t ]+/s' => '),',

I bypassed this by adding @excludeMinify and @endExcludeMinify, but that's adding and comments to production.
If we add this to all user inputs, that will cost us hundreds of megabytes of traffic per month (comment size multiplied by inputs multiplied by users count multiplied by pageviews (at least: 57 bytes * 15 user's input fields (maybe more, the maximum is about 1000) * about at least 100.000 page views (for all users) by month (real count can be times more) = about 85.5mb for absolutely unnecessary for users data, maximum up to 57 GB per month).

Is it possible to add some additional configs like disabling some minifications and adding custom minifications
or modify the regex to add space after '),' like this '), ' (simple way),
or ignore values from some HTML tags like <h1-6> <p> <span> <title> <meta> (like og:description) etc, which can contain the user's input, because in our case all is affected (I think best of the best but hard to implement)

What do you think about this?

@RChutchev
Copy link
Author

Package ver. 3.3.4

@RChutchev
Copy link
Author

We've required this package because Cloudflare Auto Minify is deprecated and will be removed according to the CF announcement.
image

@RChutchev
Copy link
Author

Also, a good idea to add this regex to remove /* Comments like this */

'/\/\*.*?\*\//'                => "",

@RChutchev
Copy link
Author

@dipeshsukhia, could you please participate?

@wilianmaique
Copy link

news ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants