Skip to content

Tighten CSP: remove inline styles + unused icon font (style-src & font-src → 'self')#17

Merged
jansroka merged 3 commits into
mainfrom
tighten-csp-remove-inline-styles
Jul 8, 2026
Merged

Tighten CSP: remove inline styles + unused icon font (style-src & font-src → 'self')#17
jansroka merged 3 commits into
mainfrom
tighten-csp-remove-inline-styles

Conversation

@jansroka

@jansroka jansroka commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Tightens the Content-Security-Policy by removing the two things that forced loose directives, at the same time cleaning up the HTML/CSS.

style-src 'self' 'unsafe-inline'style-src 'self'

Moved all 6 inline style= attributes into CSS classes:

  • 5 per-project background tints on .projekt-block cards (projekte.html) → .projekt-block--{impfen,labhive,coronika,dw,did} in custom.css
  • text-align: end on the letter date (offenerbrief-epa-2025.html) → .text-end

Colours/alignment are unchanged (verified byte-for-byte in the purged production CSS). Confirmed the built _site has zero inline style= attributes, <style> blocks, on*= handlers, or javascript: URIs — so nothing else needed the inline allowance.

font-src 'self' data:font-src 'self'

The only thing requiring data: was an embedded webflow-icons @font-face (~2.6 KB base64 TTF data URI). That icon font is unused — no w-icon- class exists anywhere in source or the built site, and PurgeCSS already strips it from production. Removed the @font-face from webflow.css (the inert .w-icon-* rules are left as-is; they match nothing). All remaining fonts are the same-origin Inter webfont under /assets/fonts/.

Resulting CSP

default-src 'self'; img-src 'self' data:; style-src 'self'; font-src 'self';
object-src 'none'; base-uri 'self'; form-action 'self'

(img-src keeps data: — data-URI images still exist in the CSS.)

Verification

webflow.css braces balanced (valid), Inter fonts intact, no data: font in _site, project-card colours unchanged in purged CSS; jekyll build, purge-css, html-proofer, and prettier --check all pass. Updated memory/csp-policy.md to match.

Noted, not done (out of scope)

The 5 project logos in projekte.html have empty alt="" — an a11y gap (likely among the pa11y findings). Happy to fix in a follow-up.

🤖 Generated with Claude Code

jansroka and others added 3 commits July 8, 2026 22:16
Moves the 6 inline style="..." attributes into CSS classes so the CSP can
drop 'unsafe-inline' from style-src:
- 5 per-project background tints on .projekt-block cards (projekte.html) ->
  .projekt-block--{impfen,labhive,coronika,dw,did} in custom.css
- text-align:end on the letter date (offenerbrief) -> .text-end
Colours/alignment unchanged.

CSP style-src is now `'self'` (was `'self' 'unsafe-inline'`). Verified: the
built _site has zero inline style attributes, on*= handlers, <style> blocks or
javascript: URIs, so nothing else needs the inline allowance. The new classes
survive PurgeCSS (they are referenced in the HTML). Build, html-proofer, and
prettier all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…self'

The webflow-icons @font-face embedded a ~2.6 KB base64 TTF as a data: URI,
which was the only reason font-src needed `data:`. That icon font is unused:
no `w-icon-` class exists in any page (verified in source and built _site),
and PurgeCSS already strips it from production CSS.

Removed the @font-face block from webflow.css (the inert `.w-icon-*` rules are
left as-is — they match nothing and are purged in prod) and dropped `data:`
from font-src. All remaining fonts are the same-origin Inter webfont under
/assets/fonts/, so font-src is now `'self'`.

Verified: webflow.css still balanced/valid, Inter fonts intact, build +
purge-css + html-proofer + prettier pass, no data: font remains in _site, and
the project-card colours are unchanged in the purged production CSS.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…elf'

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jansroka jansroka merged commit 346676c into main Jul 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant