-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
PRCE error handling #67
Comments
Hi, thanks for the good bug report. :) The problem is https://regex101.com/r/7EBtDM/1 |
Thanks for your fast feedback! 🙂 Looks like a smart solution, works for me! |
Will you release a tag for this fix? Just so I can adjust my constraint setting in my |
Version 4.4.9 with upstream fixes from "voku/simple_html_dom" are released. |
Thanks a lot! |
On a legacy project, I'm facing issues with some client who (I don't really know how) has inserted base64 encoded images.
Further more, those images aren't optimized at all (uncompressed PNG for photos...), resulting in huge base64 strings (multiple images up to 2mo):
What is this feature about (expected vs actual behaviour)?
When minifying such HTML, I end up with an empty string because this replacement fails:
HtmlMin/src/voku/helper/HtmlMin.php
Lines 1375 to 1381 in 4f70058
Because it exceeds the
pcre.backtrack-limit
and returns aPREG_BACKTRACK_LIMIT_ERROR
.I'm fully aware this is all wrong: wrong image format for photo and more importantly, large images sources should be inserted as URLs.
However, technically speaking, all this crap is still valid HTML (the page displays when unminified) and I think such cases (even if it's kind of an edge case) should not fail.
Thus, I wonder if a sanity check should be inserted somewhere to prevent the script from failing and returning an empty string? Maybe catch errors on all
preg_
calls and return the unminified HTML if an error occured? Or check the string length against thepcre.backtrack-limit
value?Wrapping
preg_
calls the Guzzlejson_decode
way could be a nice solution (because it would not only handlebacktrack-limit
errors but all kinds ofpreg_
errors)?https://github.com/guzzle/guzzle/blob/74ca2cb463a7a99a0b99f195ca809cc4ba6c3147/src/Utils.php#L281-L301
What do you think?
How can I reproduce it?
Try to minify some HTML with length that exceeds the
pcre.backtrack-limit
.Does it take minutes, hours or days to fix?
I think a couple hours should be enough, I can submit a PR but would like your feedback on the different proposed solutions before working something out.
The text was updated successfully, but these errors were encountered: