fix: CSS not allowed by subresource integrity (disable for now)
2 files changed, 9 insertions(+), 19 deletions(-)
changed files
M frontend/assets.go → frontend/assets.go
@@ -1,8 +1,6 @@ package frontend import ( - "crypto/sha256" - "encoding/base64" "fmt" "hash/fnv" "io"@@ -13,10 +11,9 @@ "github.com/Southclaws/fault/fmsg" ) type Asset struct { - URL string - ETag string - Filename string - Base64SHA256 string + URL string + ETag string + Filename string } type AssetCollection struct {@@ -47,17 +44,15 @@ return nil, fault.Wrap(err, fmsg.Withf("could not open file %s", filename)) } defer file.Close() - shasum := sha256.New() hash := fnv.New64a() - if _, err := io.Copy(io.MultiWriter(shasum, hash), file); err != nil { + if _, err := io.Copy(hash, file); err != nil { return nil, fault.Wrap(err, fmsg.Withf("could not hash file %s", filename)) } return &Asset{ - URL: "/" + filename, - ETag: fmt.Sprintf(`W/"%x"`, hash.Sum(nil)), - Filename: filename, - Base64SHA256: base64.StdEncoding.EncodeToString(shasum.Sum(nil)), + URL: "/" + filename, + ETag: fmt.Sprintf(`W/"%x"`, hash.Sum(nil)), + Filename: filename, }, nil }
M internal/components/page.go → internal/components/page.go
@@ -126,16 +126,11 @@ ) } func css(css *frontend.Asset) g.Node { - return Link(Href(css.URL), Rel("stylesheet"), - Integrity("sha256-"+css.Base64SHA256)) + return Link(Href(css.URL), Rel("stylesheet")) } func script(s *frontend.Asset) g.Node { - return Script( - Src(s.URL), - Defer(), - g.Attr("integrity", "sha256-"+s.Base64SHA256), - ) + return Script(Src(s.URL), Defer()) } func sourceNameAndType(source *config.Source) string {