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(server): match ignore wildcards by UTF-8 byte (#37927)
Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com>
Simone committed
Nov 17, 2026 at 06:47 UTC
a6016e64f8693a24600f1f2cce7419f436c66ce2
2 files changed
+11
-2
apps/server/src/workspace/IgnorePatterns.test.ts
+3
@@ -32,6 +32,9 @@ describe("parseIgnoreFile", () => {
32
expect(decide("link-[0-9]", "link-7")).toBe("ignored");
33
expect(decide("link-[!0-9]", "link-7")).toBeUndefined();
34
expect(decide("link-?", "link-/")).toBeUndefined();
35
+ expect(decide("link-?", "link-ø")).toBeUndefined();
36
+ expect(decide("link-??", "link-ø")).toBe("ignored");
37
+ expect(decide("link-ø", "link-ø")).toBe("ignored");
38
expect(decide("\\!bang\n\\#hash\nstar\\*", "!bang")).toBe("ignored");
39
expect(decide("\\!bang\n\\#hash\nstar\\*", "#hash")).toBe("ignored");
40
expect(decide("\\!bang\n\\#hash\nstar\\*", "starx")).toBeUndefined();
apps/server/src/workspace/IgnorePatterns.ts
+8
-2
@@ -21,6 +21,12 @@ interface Pattern {
21
22
export type IgnoreDecision = "ignored" | "included";
23
24
+const utf8 = new TextEncoder();
25
+
26
+// Git wildcards consume UTF-8 bytes, including inside character classes.
27
+const globBytes = (value: string) =>
28
+ Array.from(utf8.encode(value), (byte) => String.fromCharCode(byte));
29
+
30
function parseClass(chars: ReadonlyArray<string>, start: number) {
31
let index = start + 1;
32
const negated = chars[index] === "!" || chars[index] === "^";
@@ -58,7 +64,7 @@ function parseLine(rawLine: string): Pattern | undefined {
64
const anchored = line.slice(0, -1).includes("/");
65
if (line.startsWith("/")) line = line.slice(1);
66
61
- const chars = Array.from(line);
67
+ const chars = globBytes(line);
68
const tokens: Token[] = anchored ? [] : [{ type: "folders" }];
69
// A `[` that never closes leaves every later `[` unclosed too, so one failed scan settles them
70
// all; rescanning the suffix for each would make `[[[[…` quadratic.
@@ -158,7 +164,7 @@ export function parseIgnoreFile(contents: string): IgnoreFile {
164
const patterns = contents.split("\n").flatMap((line) => parseLine(line) ?? []);
165
return {
166
decide: (relativePath, isFolder) => {
161
- const path = Array.from(relativePath);
167
+ const path = globBytes(relativePath);
168
for (let index = patterns.length - 1; index >= 0; index -= 1) {
169
const pattern = patterns[index]!;
170
if (pattern.folderOnly && !isFolder) continue;