From 330b6d86c34a5680ae264dc074f67d3b5c0a5dcb Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Thu, 3 Dec 2026 07:49:26 -0600 Subject: [PATCH 1/2] security: disable unsafe-style in default csp policy --- csp_test.go | 1 - security.go | 1 - 2 files changed, 2 deletions(-) diff --git a/csp_test.go b/csp_test.go index b0940f3..e4f85c4 100644 --- a/csp_test.go +++ b/csp_test.go @@ -20,7 +20,6 @@ func Test_BuildCSP_scriptSrc(t *testing.T) { want := "default-src 'self'; " + "script-src 'self' https://cdn.jsdelivr.net; " + "style-src 'self'; " + - "style-src-attr 'unsafe-inline'; " + "img-src 'self'; " + "font-src 'self'; " + "connect-src 'self'; " + diff --git a/security.go b/security.go index 39cc2e3..6f49f9e 100644 --- a/security.go +++ b/security.go @@ -17,7 +17,6 @@ import ( const DefaultCSP = "default-src 'self'; " + "script-src 'self'; " + "style-src 'self'; " + - "style-src-attr 'unsafe-inline'; " + "img-src 'self'; " + "font-src 'self'; " + "connect-src 'self'; " + From b9c859200ec7b1b97d6be4cda6e9c60dd7072396 Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Thu, 3 Dec 2026 07:55:08 -0600 Subject: [PATCH 2/2] readme: clarifications around usafe script sources --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/README.md b/README.md index e8ba50b..d2faf2a 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,19 @@ csp := webtools.BuildCSP( The `With*` options append to their source-list directive, retaining the default `'self'` source. Use `WithCSP` to replace the policy outright. +To permit inline styles (a `