Skip to content

fix(addon): make font url() rewrite quote-aware to prevent parsable-css crash - #942

Merged
aaspinwall merged 1 commit into
mainfrom
fix/parsable-css-font-url-quotes
Jun 29, 2026
Merged

fix(addon): make font url() rewrite quote-aware to prevent parsable-css crash#942
aaspinwall merged 1 commit into
mainfrom
fix/parsable-css-font-url-quotes

Conversation

@aaspinwall

Copy link
Copy Markdown
Collaborator

What changed?

Made the webfont url() rewrite in packages/addon/scripts/build.sh quote-aware, and added a build-time guard.

  • The rewrite that converts absolute url(/fonts/...) to relative url(../fonts/...) previously used s{url\(/fonts/}{url(../fonts/}g, which only matched the unquoted form. It now captures an optional quote ((["\x27]?)) and re-emits it, so url(/fonts/, url('/fonts/, and url("/fonts/ are all rewritten.
  • Added a guard that greps the bundled CSS after the rewrite and fails the build (printing the offending lines) if any absolute /fonts/ url() survived, so a broken bundle can never silently ship again.

I verified the new regex against the actual deployed CSS: all 36 url('/fonts/...') references convert to url('../fonts/...'), and the guard passes on the rewritten output (and fails on the pre-fix input).

AI disclosure: this change was diagnosed and written by Claude (agent), reviewed and directed by the author. The author identified the failing try run; the agent traced the root cause from the CI log, wrote the one-line regex fix and guard, and verified the rewrite against the deployed CSS.

Why?

A try push crashed in Thunderbird's static browser_parsable_css.js check:

TEST-UNEXPECTED-CRASH | comm/mail/base/test/browser/static/browser_parsable_css.js
PROCESS-CRASH | Missing chrome or resource URLs:
  resource://builtin-addons/fonts/Inter/Inter-Regular.woff2 [@ mozilla::net::CheckForBrokenChromeURL]

The bundled CSS shipped absolute url('/fonts/...') font references. Loaded as a built-in add-on, an absolute /fonts/... URL resolves against the resource:// protocol root (resource://builtin-addons/fonts/...) rather than the add-on's own directory, so the font is missing and the static check fatally crashes (Bug 2036665).

build.sh already had a rewrite step meant to prevent exactly this, but its regex only matched unquoted url(/fonts/. Production (minified) builds strip quotes so the bug stayed hidden; the dev/unminified build that was deployed preserved the source single quotes (url('/fonts/...')), so the rewrite was a no-op and the absolute paths shipped — crashing CI.

Failing run: https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=51fc152ffe02dc4a5ec85cedbb188463172bb7f2&selectedTaskRun=dHZ5CqI4QRSnRU3g-hftrg.0

Limitations and Notes

  • The font files themselves were always packaged correctly; only the CSS URL form was wrong.
  • Follow-up (process, not code): the deployed .xpi was a dev/unminified build, which is what exposed the gap. Standardizing the deploy/release path on the production pnpm build would add defense in depth, though this fix makes the rewrite correct for both modes.
  • Still needs a fresh .xpi rebuild + re-deploy into the comm tree and a new try push to confirm the suite goes green.

Applicable Issues

Closes #941

Screenshots

N/A — build-script change.

…ss crash

The build.sh rewrite that converts absolute url(/fonts/...) to relative
url(../fonts/...) only matched the unquoted form. Dev/unminified builds
preserve the source single quotes (url('/fonts/...')), so the rewrite was
a no-op and the add-on shipped absolute font URLs. Loaded as a built-in
add-on these resolve against resource://builtin-addons/fonts/... instead of
the add-on's own directory, crashing Thunderbird's static
browser_parsable_css.js check (Bug 2036665).

Capture the optional quote and re-emit it so both quoted and unquoted forms
are rewritten, and add a build-time guard that fails the build if any
absolute /fonts/ url() survives the rewrite.

Closes #941

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@aaspinwall
aaspinwall requested a review from radishmouse June 29, 2026 16:37
@aaspinwall
aaspinwall merged commit 8055047 into main Jun 29, 2026
20 checks passed
@aaspinwall
aaspinwall deleted the fix/parsable-css-font-url-quotes branch June 29, 2026 16:47
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.

Built-in add-on crashes browser_parsable_css.js: font url() rewrite misses quoted absolute paths

1 participant