Allow data: fonts in the standalone HTML CSP#285
Conversation
`_STANDALONE_CSP` declared no `font-src`, so font loads fell back to
`default-src 'none'` and every face was blocked — including the data-URL
`@font-face` that docs/styling/themes-and-tokens.md documents as the portable
brand-font recipe. A standalone export silently rendered in system-ui, leaving
only a console CSP violation, and the same failure reached Chromium PNG because
it renders that document.
Add `font-src data:` — exactly `data:`, matching the existing `img-src data:`
shape, so no network origin can serve a face and a standalone file stays
self-contained offline.
The documented recipe had a second blocker: the chart root carries a computed
`font` shorthand that an ordinary `.xy { font-family: ... }` rule cannot
outrank. Point the docs at `xy.theme(font_family=...)`, which writes that
shorthand.
The CSP is duplicated in scripts/render_smoke_nonumpy.py and asserted equal by
the existing test, so update both. The new test asserts `font-src` is exactly
`data:` — the old coverage only checked the `worker-src` substring, which is
why this went unnoticed.
|
Warning Review limit reached
Next review available in: 53 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
Problem
_STANDALONE_CSPdeclares nofont-src, so font loads fall back todefault-src 'none'and every face is blocked — including the data-URL@font-facethatdocs/styling/themes-and-tokens.mddocuments as the portable brand-font recipe.A standalone export silently rendered in
system-ui, leaving only a console CSPviolation to explain it. Because
to_image(engine=Engine.chromium)renders thatsame document, the failure reached Chromium PNG too — the path the docs point at
precisely when font fidelity matters.
Captured live in a browser against a generated export:
Before / after
Same script, same embedded face (Chalkduster as a
data:URL under a customfamily name, so it can only come from the data URL — no local fallback can
satisfy it). Left:
origin/main. Right: this branch.After the fix: zero CSP violations,
document.fonts.check(...)→true.Fix
Add
font-src data:beside the existingimg-src data:. Exactlydata:— nonetwork origin can serve a face, so a standalone file stays self-contained
offline, which is the property
default-src 'none'exists to protect.The recipe had a second blocker, also fixed here in docs: the chart root
carries a computed
fontshorthand that an ordinary.xy { font-family: ... }rule cannot outrank. The docs now use
xy.theme(font_family=...), which writesthat shorthand — verified in the screenshot above.
Notes
scripts/render_smoke_nonumpy.pyand assertedequal by an existing test, so both move together.
font-srcis exactlydata:. Existing coverage onlychecked the
worker-srcsubstring and self-consistency, which is why thiswent unnoticed.
spec/process/security-audit-2026-07-06.mdgets a status entry, matching howthe
worker-srcrelaxation was recorded.Found during a customizability audit of the styling surface.