-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Fingerprinting + PostProcess + HTML minify causes HTML validation errors #8884
Comments
Unable to reproduce with v0.87.0. git clone --single-branch -b hugo-github-issue-8884 https://github.com/jmooring/hugo-testing hugo-github-issue-8884
cd hugo-github-issue-8884
hugo server --minify |
I have tested your repo and indeed I am also unable to reproduce it so I went again to my site to test it further and I found the most likely culprit: PostProcess. |
Verified. Updated MRE: git clone --single-branch -b hugo-github-issue-8884 https://github.com/jmooring/hugo-testing hugo-github-issue-8884
cd hugo-github-issue-8884
hugo server --minify Changing |
@jmooring I think that with minification as part of the publisher chain, the best we currently can do is to make sure the attribute values stays quoted. I don't see any harm in adding a "=" to the suffix. We could do it just for the I do have a improved (but little bit more involved design for these post processings) somewhere, with a new |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What version of Hugo are you using (
hugo version
)?0.87
Does this issue reproduce with the latest release?
Yes
What is happening?
When building a site that uses fingerprints for the resources while also minifying the final output with the option
keepQuotes = false
the output will cause HTML validation errors due to the fact that the fingerprint is base64 encoded and can contain=
which break HTML when unquoted.From my observations the final fingerprint is added to the site after the minification took process so the minifier cannot detect the base64 string and keep the quotes.
What to expect?
Minification should take place after all other build steps are done so the output processed by the minifier is definitely the final output and does not get processed any further after minification.
I tested the issue with the online version of the used minifier and it in fact keeps quotes when it encounters a base64 encoded string while removing all other quotes which then allows the document to pass validation
How to reproduce?
{{§css = resources.Get "my/styles.css" | fingerprint}}
<link rel="stylesheet" href="{{ $css.RelPermalink }}" integrity="{{ $css.Data.Integrity }}" crossorigin="anonymous">
keepQuotes = false
hugo --minify
=
characters in its source (if the hash requires them)The text was updated successfully, but these errors were encountered: