The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 08:30 UTC
fix(shared): theme CSS check no longer rejects @import text inside a string (#38150)
Co-authored-by: Grok 4.7 <noreply@x.ai> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 17, 2026 at 15:21 UTC
31706f3d41edd605aaba676bd75d9f77b260f4c2
2 files changed
+17
-6
packages/shared/src/themeCss.test.ts
+7
@@ -30,6 +30,13 @@ describe("themeCssValueFetches", () => {
30
});
31
32
describe("themeCssLoadsRemoteFiles", () => {
33
+ it.each([
34
+ ['[data-chat-header]::after { content: "@import"; }', false],
35
+ ['@import "x.css";', true],
36
+ ])("%s", (css, loads) => {
37
+ expect(themeCssLoadsRemoteFiles(css)).toBe(loads);
38
+ });
39
+
40
it("allows a url() inside a data: address", () => {
41
expect(
42
themeCssLoadsRemoteFiles(`.repro { background-image: url('${SVG_WITH_OWN_GRADIENT}'); }`),
packages/shared/src/themeCss.ts
+10
-6
@@ -8,12 +8,16 @@ const URL_NOT_LOCAL = /url\((?![ \t\n\f\r]*["']?(?:data:|#))/i;
8
const URL_OR_STRING =
9
/url\((?![ \t\n\f\r]*["'])[^)]*|url\([ \t\n\f\r]*("[^"\n\r\f]*"|'[^'\n\r\f]*')|"[^"\n\r\f]*"|'[^'\n\r\f]*'/gi;
10
11
-function fetchesByText(code: string): boolean {
12
- const outsideStrings = code.replace(URL_OR_STRING, (token, urlString: string | undefined) => {
11
+/** The code with its strings removed, keeping `url(` where a quoted url() can load a file. */
12
+function withoutStrings(code: string): string {
13
+ return code.replace(URL_OR_STRING, (token, urlString: string | undefined) => {
14
if (urlString !== undefined) return /^["'](?:data:|#)/i.test(urlString) ? "" : "url(";
15
return token.startsWith('"') || token.startsWith("'") ? "" : token;
16
});
16
- return FETCHES_BY_STRING.test(outsideStrings) || URL_NOT_LOCAL.test(outsideStrings);
17
+}
18
+
19
+function fetchesOutsideStrings(code: string): boolean {
20
+ return FETCHES_BY_STRING.test(code) || URL_NOT_LOCAL.test(code);
21
}
22
23
/**
@@ -22,13 +26,13 @@ function fetchesByText(code: string): boolean {
26
* so every value that still has a backslash is refused.
27
*/
28
export function themeCssValueFetches(value: string): boolean {
25
- return value.includes("\\") || fetchesByText(value);
29
+ return value.includes("\\") || fetchesOutsideStrings(withoutStrings(value));
30
}
31
32
/** A text check for early feedback. CSS escapes can dodge it; the client check is the guard. */
33
export function themeCssLoadsRemoteFiles(css: string): boolean {
30
- const code = css.replace(/\/\*[\s\S]*?\*\//g, "");
31
- return /@import/i.test(code) || fetchesByText(code);
34
+ const code = withoutStrings(css.replace(/\/\*[\s\S]*?\*\//g, ""));
35
+ return /@import/i.test(code) || fetchesOutsideStrings(code);
36
}
37
38
/**