Skip to content

[Bug]: Theme CSS rejects url(%23g) inside a data SVG background #36679

Closed

Description

@Nexxol

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

packages/contracts or packages/shared

Steps to reproduce

  1. Save this as url-repro.json. The background is an SVG embedded as a data: address, and its rect is filled with the SVG's own gradient. In this non-base64 address, the # of url(#g) is written %23, because a literal # would start the outer address's fragment. The selector deliberately avoids app UI. An accepted publish would still select the theme and its terminal-cursor color.
{
  "version": 1,
  "name": "Url Repro",
  "appearance": "dark",
  "colors": { "terminalCursor": "#8080ff" },
  "css": ".t3-repro-nonexistent{background-image:url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2240%22 height=%2240%22%3E%3ClinearGradient id=%22g%22%3E%3Cstop stop-color=%22red%22/%3E%3Cstop offset=%221%22 stop-color=%22blue%22/%3E%3C/linearGradient%3E%3Crect width=%2240%22 height=%2240%22 fill=%22url(%23g)%22/%3E%3C/svg%3E')}"
}
  1. Call t3_theme_set with themeId: "url-repro" and that object as theme. It is refused with the error below.
  2. For comparison, run t3 theme set url-repro.json --base-dir <new empty directory>. It publishes.

Expected behavior

t3_theme_set accepts this self-contained SVG background, and the client retains its background-image declaration. The guide permits data: image addresses. Here %23g becomes #g inside the SVG and refers only to its own gradient.

Actual behavior

t3_theme_set refuses the theme with the error below. The CLI comparison publishes the identical file in the isolated base directory.

At main 179c032b3, URL_NOT_LOCAL in packages/shared/src/themeCss.ts matches the inner url(%23g) inside the quoted data address. The server checks it in apps/server/src/environmentTheme.ts; the CLI publishing path in apps/server/src/cli/theme.ts does not run that text check.

A standalone test using the actual shared and web modules from that commit, with module imports/exports and TypeScript types removed, confirms that applyThemeCss in apps/web/src/themeCss.ts removes this background-image declaration in headless Chromium 151. The parenthesis-encoded version described below survives.

Replacing %23 with a literal # passes the checks but makes this SVG fail to decode in Chromium 151.

Impact

Minor bug or occasional failure

Version or commit

v0.1.10-nightly.20261114.4669. Source and standalone client tests at main 179c032.

Environment

Linux desktop app (Nightly). Agent: Claude Fable 5.2 through Claude Code.

Logs or stack traces

Theme "url-repro" has CSS that loads files. Remove @import, image-set(), and url() that is not data: or #id.

Workaround

Percent-encode the inner parentheses too: fill=%22url%28%23g%29%22. Both data addresses decode to identical SVG. The encoded version passes the shared checks, survives applyThemeCss, and paints the same gradient in headless Chromium 151. t3_theme_set accepted a larger theme that used this encoding for a pattern and a filter reference.

Drafted by Claude Fable 5.2 and reviewed by GPT 6.1 Sol on behalf of the reporter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions