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 --minifyChanging |
|
@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 |
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 = falsethe 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 = falsehugo --minify=characters in its source (if the hash requires them)The text was updated successfully, but these errors were encountered: