Skip to content

fix(themes): keep inline SVG data URLs with double quotes in theme CSS - #44554

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
saphid:hunter/c-528853db17
Nov 28, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
saphid:hunter/c-528853db17

Conversation

@saphid

@saphid saphid commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Problem

Theme CSS declarations using single-quoted inline SVG data: URLs with double-quoted SVG attributes pass server publishing (themeCssLoadsRemoteFiles) but are silently stripped by the web and desktop CSS sanitizer (applyThemeCss). When Chromium parses the stylesheet into CSSOM, rule.style.getPropertyValue(...) serializes the URL with double quotes and backslash-escaped inner quotes (\"), which withoutStrings(..., false) in packages/shared/src/themeCss.ts rejected because it refused any quoted url() containing \.

Deterministic repro on origin/main (09418562d601df5a451124c2bccb35a6e0c394b8):

  • Add and select a theme in /settings/appearance with CSS:
    [data-settings-page-scroll] { background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8"><circle cx="4" cy="4" r="2" fill="red"/></svg>'); }
  • Or run themeCssValueFetches(String.raw\url("data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg\"><circle cx="4" cy="4" r="2" fill="red"/>")`)(the exact Chromium CSSOM serialization ofgetPropertyValue("background-image")`).
  • Observed: themeCssLoadsRemoteFiles(css) returns false, themeCssValueFetches(serialized) returns true, and stripDeclarations drops background-image (getComputedStyle(document.querySelector('[data-settings-page-scroll]')).backgroundImage === "none").
  • Expected: themeCssValueFetches returns false for closed quoted url("data:...") / url("#...") values whose scheme prefix is literal data: or # even when the payload contains escaped quotes, preserving background-image while still rejecting escaped schemes (url("\64 ata:...")) and remote URLs.

Change

Removed the early if (!stylesheet && url.includes("\\")) return token; bailout in withoutStrings (packages/shared/src/themeCss.ts) and updated the doc comments. Because urlString is matched by the full CSS STRING grammar and tested against /^[ \t\n\f\r]*["']?(?:data:|#)/i, escapes inside a quoted data: or # payload cannot alter the scheme or break out of the string token, while escaped schemes, unquoted url() values with escapes, and remote URLs remain rejected. Because both web and desktop clients use @t3tools/shared/themeCss via apps/web/src/themeCss.ts (and mobile does not use theme CSS), this single shared fix covers all affected surfaces.

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.

Verification

  • Base failure (09418562d601df5a451124c2bccb35a6e0c394b8): vp test run packages/shared/src/themeCss.test.ts -t "themeCssValueFetches" failed on the Chromium-serialized inline SVG data: URL (expected true to be false), while themeCssLoadsRemoteFiles returned false.
  • Head pass (da19133679bdfaf7d4d5423d935ade3b94b09c6e): vp test run packages/shared/src/themeCss.test.ts passed 2/2 consecutive runs (40/40 tests, including escaped-scheme and escaped-remote-URL rejection cases).
  • Changed-files gate: vp run check:changed exited 0 (format, lint, knip, typecheck across 38 packages, and 2 affected test files / 42 tests).
  • Before/after evidence transcript: https://gist.github.com/saphid/882e6ea10737ddf165bc1d089f9b171f
  • Not shown: Live Chromium/Electron UI rendering and Playwright scenarios:prove screenshot capture (covered by unit verification of the shared themeCssValueFetches gate and runtime before/after transcript).

Authored by Gemini 4 Neon (Antigravity); reviewed by Kimi K3.1 Pro (Model Hub).

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 28, 2026
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5097a08 and eaae362.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The theme CSS check changes how it processes escaped quoted url() tokens in declaration values. Tests now cover an inline SVG data URL, an escaped data: scheme, and a remote URL with an escaped quote.

Changes: Theme CSS URL classification

Layer / File(s) Summary
Escaped quoted URL handling
packages/shared/src/themeCss.ts, packages/shared/src/themeCss.test.ts
The check no longer preserves escaped quoted URL tokens as fetch candidates in declaration values. Tests expect an inline SVG data URL not to fetch, and expect an escaped data: scheme and a remote URL with an escaped quote to fetch.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Possibly related PRs

Suggested labels: bugfix

Suggested reviewers: juliusmarminge, macroscopeapp

Merge Risk: Minimal · previous review 5097a

Theme CSS declarations with inline SVG data URLs serialized by Chromium are now preserved, while remote and escaped-scheme URLs are still classified as fetching. Unit tests cover the changed behavior, and the change is easy to revert. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: it fixes theme CSS so inline SVG data URLs that use double quotes are kept. The title follows the conventional commit form and matches the changed logic in themeCss.ts…
Description check Passed The description follows the template. It has Problem, Change, Scope, and Verification sections, and each one has concrete content. The Problem section gives a reproduction and expected behavior. The C…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: it fixes theme CSS so inline SVG data URLs that use double quotes are kept. The title follows the conventional commit form and matches the changed logic in themeCss.ts, which removes the early rejection of quoted url() values that contain backslashes.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, and Verification sections, and each one has concrete content. The Problem section gives a reproduction and expected behavior. The Change section explains the removed bailout and why the escape handling stays safe. The Scope section gives a reason for no linked issue. The Verification section lists focused test runs with results, and it states what was not checked (live Chromium/Electron rendering and Playwright screenshots). The template asks for before/after screenshots for UI changes. The author gives a before/after transcript link and explains why screenshots were not captured, which is a partial gap. The model and harness line is present at the end.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c0f45b6 and 5097a08.

Files selected for processing: 2

  • packages/shared/src/themeCss.test.ts
  • packages/shared/src/themeCss.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 28, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Chromium, 1280×800, light appearance, fresh isolated state on each commit. Open Settings → Appearance → Create theme, name it Dots, expand Custom CSS, paste the reporter's CSS verbatim, and create the theme.

The scenario runner exited 0: base failed because computed background-image stayed none; head passed and visibly rendered the red-dot pattern.

Before After
Before: inline SVG background missing After: inline SVG red dots render
b6cbe0fca8 eaae362ced
Before recording After recording

Scenario source

Not shown:

  • Desktop was not run; this proof covers the web client.
  • Remote URLs, escaped schemes, and the single-quoted-attribute control were not exercised; the scenario covers the reported double-quoted inline SVG defect.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 28, 2026
@juliusmarminge
juliusmarminge merged commit 5b6b26d into pingdotgg:main Nov 28, 2026
60 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 28, 2026
CesarDavidXI pushed a commit to CesarDavidXI/t3code-cd that referenced this pull request Nov 28, 2026
pingdotgg#44554)

Co-authored-by: SAPHID <saphid@users.noreply.github.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants