You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(themes): keep inline SVG data URLs with double quotes in theme CSS - #44554
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")`).
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).
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).
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.
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.
pingdotgg/t3code#39217: Changes escape and URL classification rules in the same shared theme CSS module.
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: 4
Check name
Status
Explanation
Title check
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
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
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
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.
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.
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.
pingdotgg#44554)
Co-authored-by: SAPHID <saphid@users.noreply.github.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:XS0-9 changed lines (additions + deletions).vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 (\"), whichwithoutStrings(..., false)inpackages/shared/src/themeCss.tsrejected because it refused any quotedurl()containing\.Deterministic repro on
origin/main(09418562d601df5a451124c2bccb35a6e0c394b8):/settings/appearancewith 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>'); }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")`).themeCssLoadsRemoteFiles(css)returnsfalse,themeCssValueFetches(serialized)returnstrue, andstripDeclarationsdropsbackground-image(getComputedStyle(document.querySelector('[data-settings-page-scroll]')).backgroundImage === "none").themeCssValueFetchesreturnsfalsefor closed quotedurl("data:...")/url("#...")values whose scheme prefix is literaldata:or#even when the payload contains escaped quotes, preservingbackground-imagewhile still rejecting escaped schemes (url("\64 ata:...")) and remote URLs.Change
Removed the early
if (!stylesheet && url.includes("\\")) return token;bailout inwithoutStrings(packages/shared/src/themeCss.ts) and updated the doc comments. BecauseurlStringis matched by the full CSSSTRINGgrammar and tested against/^[ \t\n\f\r]*["']?(?:data:|#)/i, escapes inside a quoteddata:or#payload cannot alter the scheme or break out of the string token, while escaped schemes, unquotedurl()values with escapes, and remote URLs remain rejected. Because both web and desktop clients use@t3tools/shared/themeCssviaapps/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
09418562d601df5a451124c2bccb35a6e0c394b8):vp test run packages/shared/src/themeCss.test.ts -t "themeCssValueFetches"failed on the Chromium-serialized inline SVGdata:URL (expected true to be false), whilethemeCssLoadsRemoteFilesreturnedfalse.da19133679bdfaf7d4d5423d935ade3b94b09c6e):vp test run packages/shared/src/themeCss.test.tspassed 2/2 consecutive runs (40/40 tests, including escaped-scheme and escaped-remote-URL rejection cases).vp run check:changedexited0(format,lint,knip,typecheckacross 38 packages, and 2 affected test files / 42 tests).scenarios:provescreenshot capture (covered by unit verification of the sharedthemeCssValueFetchesgate and runtime before/after transcript).Authored by Gemini 4 Neon (Antigravity); reviewed by Kimi K3.1 Pro (Model Hub).