dipeshsukhia / laravel-html-minify

laravel minify html output
MIT License
66 stars 22 forks source link

Bug with strings values minification #20

Open RChutchev opened 1 week ago

RChutchev commented 1 week ago

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 commented 1 week ago

Package ver. 3.3.4

RChutchev commented 1 week ago

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

RChutchev commented 1 week ago

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

'/\/\*.*?\*\//'                => "",
RChutchev commented 3 hours ago

@dipeshsukhia, could you please participate?