Skip to content

Commit

Permalink
Use md5 instead of default sha256 for generating SRI hashes (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
hlwjia authored Jan 25, 2021
1 parent 789b1f8 commit 9e99493
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{{- $isHLJSdisabled := (.Site.Params.assets.disableHLJS | default .Params.disableHLJS ) }}
{{- if (and (eq .Kind "page") (ne .Layout "archives") (ne .Layout "search") (not $isHLJSdisabled)) }}
{{- if not .Site.Params.assets.disableFingerprinting }}
{{- $highlight := slice (resources.Get "js/highlight.min.js") | resources.Concat "assets/js/highlight.js" | minify | fingerprint }}
{{- $highlight := slice (resources.Get "js/highlight.min.js") | resources.Concat "assets/js/highlight.js" | minify | resources.Fingerprint "md5" }}
<script defer src="{{ $highlight.RelPermalink }}" integrity="{{ $highlight.Data.Integrity }}"
onload="hljs.initHighlightingOnLoad();"></script>
{{- else}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{{- $stylesheet := (slice $common $extended) | resources.Concat "assets/css/stylesheet.css" | minify }}

{{- if not .Site.Params.assets.disableFingerprinting }}
{{- $stylesheet := $stylesheet | fingerprint -}}
{{- $stylesheet := $stylesheet | resources.Fingerprint "md5" -}}
<link href="{{ $stylesheet.RelPermalink }}" integrity="{{ $stylesheet.Data.Integrity }}" rel="preload stylesheet"
as="style">
{{- else}}
Expand All @@ -43,7 +43,7 @@
{{- $fastsearch := resources.Get "js/fastsearch.js" | resources.ExecuteAsTemplate "js/fastsearch.js" .Site.Params.fuseOpts }}
{{- $fusejs := resources.Get "js/fuse.js" }}
{{- if not .Site.Params.assets.disableFingerprinting }}
{{- $search := (slice $fusejs $fastsearch ) | resources.Concat "assets/js/search.js" | minify | fingerprint }}
{{- $search := (slice $fusejs $fastsearch ) | resources.Concat "assets/js/search.js" | minify | resources.Fingerprint "md5" }}
<script defer src="{{ $search.RelPermalink }}" onload="loadSearch();" integrity="{{ $search.Data.Integrity }}"></script>
{{- else}}
{{ $search := (slice $fusejs $fastsearch ) | resources.Concat "assets/js/search.js" | minify }}
Expand Down

2 comments on commit 9e99493

@muhammadhanif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this error when accessing https://adityatelange.github.io/hugo-PaperMod/posts/papermod/papermod-features/.

I don't know whether it is an effect of changing fingerprinting from default sha256 to md5 or not.

error-parsing-papermod

@adityatelange
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this error when accessing https://adityatelange.github.io/hugo-PaperMod/posts/papermod/papermod-features/.

I don't know whether it is an effect of changing fingerprinting from default sha256 to md5 or not.

error-parsing-papermod

Yes it is. Nice Finding ! But it is only on few pages, it is better to revert though

Please sign in to comment.