all repos — searchix @ c4dc9b20cce2b08e7cf0f0e0b6c21fb3938177d0

Search engine for NixOS, nix-darwin, home-manager and NUR users

fix: CSS not allowed by subresource integrity (disable for now)

Alan Pearce
commit

c4dc9b20cce2b08e7cf0f0e0b6c21fb3938177d0

parent

e2b72135312274360853f51e817b83d1ccf3e5a9

2 files changed, 9 insertions(+), 19 deletions(-)

changed files
M frontend/assets.gofrontend/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.gointernal/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 {