Skip to content

fix(core): a static page with a remote font or @import warns, naming the source - #685

Merged
allisonmahmood merged 2 commits into
mainfrom
fix/586-remote-font-warnings
Oct 15, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
fix/586-remote-font-warnings

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

Stacked on #682

A static page whose @font-face loads from https://…, or whose CSS uses @import, published with warnings: []. Tier 0's content policy blocks both (font-src data:, style-src 'unsafe-inline'), so the page quietly fell back to another font and the agent never heard why.

validateHtml now reads each <style> with css-tree, which core already uses for looks, and adds one warning per blocked source, naming it:

  • @font-face source "<source>" won't load: static pages load fonts only from data: URLs. Embed the font as a data: URL or use a system font stack.
  • @import "<source>" won't load: static pages can't load other stylesheets. Inline its CSS, with any fonts embedded as data: URLs.

The page still validates. data: and in-page #fragment sources, local() and format() strings, url() outside a font src (an https background-image is allowed) and <template> content stay quiet. Escaped names such as \73rc count as the browser reads them. css-tree recurses, so CSS nested too deeply to parse is skipped rather than failing the page.

The new accept fixture remote-font.html joins the corpus, and the policy test now asserts exact warnings for every accept fixture; the others expect []. The global patchy skill's HTML safety rules now say fonts load only from data: URLs and @import never loads, and its hash in skills-lock.json is refreshed.

Tried by hand

In a pnpm dev up team environment built from this branch before it was rebased onto #678, using the environment's CLI on a page with @import url("https://example.test/theme.css"), @font-face { src: local("Brand"), url("https://example.test/brand.woff2") format("woff2") } and an https background-image:

  • patchy validate → HTML passed Patchy Cloud validation. and exactly two Warning: lines, the import and the font URL, exit 0. With --json: {"ok":true,"warnings":[…the same two…]}.
  • patchy publish, text and --json → published, with the same two warnings.
  • The same page posted straight to POST /api/publish → 201 with the same two warnings.
  • pnpm dev shot ada /acme/remote-font → the page renders in serif. The browser reports Loading the font 'https://example.test/brand.woff2' violates … "font-src data:" and Loading the stylesheet 'https://example.test/theme.css' violates … "style-src 'unsafe-inline'", the two sources the warnings name. The background image passes the policy; only its made-up host fails to resolve.
  • pnpm seed:dev publishes all five accept fixtures, remote-font.html included.

The rebase onto #678 changed no behaviour here; the policy tests and each fail-without-fix check were rerun after it.

Surfaces

  • Fixtures: the new accept fixture is read by the policy test and pnpm seed:dev.
  • CLI validate, file-mode publish and the server publish route already surface warnings. No flag, exit code or API description changed, so the README, ADR-0004 and docs/API.md stay as they are.
  • Global skill: HTML safety rules updated, hash refreshed.
  • Not applicable: wire contract, dev loop, vocabulary, migrations, company resources, served pages, reverse states, repo layout.

Closes #586

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol (xhigh) reviewed this against #586 and its triage brief. Two findings, both addressed in the last commit:

  • Medium: spreading warnings into push() could overflow the stack (a 500 at publish) on a page nesting 2,000 elements with 70,000 font sources. Fixed: warnings are appended one at a time. Since then fix(core): pathological markup can no longer stall the server #678 caps nesting at 512, and with the 512 KiB page cap the spread no longer overflows (probed to depth 505 with about 86,000 sources). The per-item push stays as headroom. Its regression test was dropped because it can no longer fail.
  • Low: escaped names such as \73rc slipped past the check. Fixed: at-rule and descriptor names are decoded with CssTree.ident.decode before comparing, as repoBuild.ts already does. One escaped case was added to the font-warning test, and it fails without the decode.

A second Sol pass on the fix commit found nothing.

@github-actions github-actions Bot added area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:core Touches the core area area:docs Touches the docs area size:m 100-500 changed lines labels Oct 15, 2026
@allisonmahmood
allisonmahmood force-pushed the fix/622-noscript-policy branch from 182f799 to eab7c16 Compare October 15, 2026 17:10
Base automatically changed from fix/622-noscript-policy to main October 15, 2026 17:19
…the source

Tier 0's content policy blocks @font-face sources other than data: URLs
and every @import, but validateHtml never read <style> contents, so a
page relying on either published with no warning and silently fell back
to another font. validateHtml now parses each <style> with css-tree and
adds one warning per blocked source. The page still validates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Decode CSS escapes before comparing at-rule and descriptor names, as a
browser does, so `\73rc` counts as `src`. Append warnings one at a time
rather than spreading them into push(), since a stylesheet can name tens
of thousands of sources.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the fix/586-remote-font-warnings branch from 8082252 to b141ee8 Compare October 15, 2026 17:20
@allisonmahmood
allisonmahmood merged commit 3c52a18 into main Oct 15, 2026
13 checks passed
@allisonmahmood
allisonmahmood deleted the fix/586-remote-font-warnings branch October 15, 2026 17:26
allisonmahmood added a commit that referenced this pull request Oct 16, 2026
…u when they fail (#720)

Release 13's What's new entry, written from `c9b8fc4`, ahead of
deploying it. `patchy` and `CURRENT_RELEASE` move to `0.13.0`, so CLIs
and patch repos installed before this deploy are told to upgrade.

| Change | PRs |
| --- | --- |
| New: Home puts the patches you use first | #713, #716, #719 |
| New: Every patch in one list | #715 |
| Improved: Each patch's page leads with Open | #717 |
| New: See when your tools are failing | #718 |
| Fixed: Everyone has a name | #687 |
| Improved: Your company's look is easier to get right | #697, #696,
#703, #688 |
| Improved: Forms follow your look's error states | #691, #692 |
| Improved: Clearer answers when a publish goes wrong | #686, #685, #689
|
| Fixed: Your agent's Patchy commands are steadier | #695, #704, #680,
#681 |
| Behind the scenes: stricter checks on static pages and tools' database
requests; malformed requests are logged | #682, #693, #683 |
| Behind the scenes: usage numbers count every publish, sharing change
and restore | #698, #699, #700, #690 |
| Test and tooling only, no line | #705, #702, #701, #694, #684, #607 |

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:core Touches the core area area:docs Touches the docs area size:m 100-500 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(core): a static page with a remote @font-face or @import publishes with no warning

1 participant