The best way to control Claude Code, Codex and more from any computer or phone
fix(ssh): preserve Unicode whitespace in Include filenames (#33273)
Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com>
Simone committed
Nov 12, 2026 at 00:06 UTC
289065a6b1c033ce0976eb1d2410ce1e8f92329f
2 files changed
+24
-5
packages/ssh/src/config.test.ts
+20
-3
@@ -14,7 +14,7 @@ function makeTempHomeDir() {
14
}
15
16
describe("ssh config", () => {
17
- it.effect("deduplicates hosts through quoted and escaped Include paths like OpenSSH", () =>
17
+ it.effect("deduplicates hosts through quoted, escaped, and Unicode Includes", () =>
18
Effect.gen(function* () {
19
const fs = yield* FileSystem.FileSystem;
20
const path = yield* Path.Path;
@@ -31,13 +31,25 @@ describe("ssh config", () => {
31
path.join(homeDir, "escaped space.conf"),
32
"Host escaped\n HostName escaped.example.com\nHost *\n",
33
);
34
+ const unicodeFiles = [
35
+ "\u00a0team\u00a0one.conf",
36
+ "team\u2003one.conf",
37
+ "team\u2028one.conf",
38
+ "team\u2029one.conf",
39
+ ].flatMap((file) => [file, `quoted-${file}`]);
40
+ for (const [index, file] of unicodeFiles.entries()) {
41
+ yield* fs.writeFileString(
42
+ path.join(sshDir, file),
43
+ `Host unicode-${index}\n HostName unicode-${index}.example.com\nHost *\n`,
44
+ );
45
+ }
46
yield* fs.writeFileString(
47
path.join(sshDir, "config"),
48
[
49
`Include "${path.join(quotedDir, "team#1=a.conf")}" # comment`,
50
`Include ${path.join(homeDir, "escaped space.conf").replaceAll(" ", "\\ ")}`,
39
- "",
40
- ].join("\n"),
51
+ `Include ${unicodeFiles.map((file, index) => (index % 2 === 0 ? file : `"${file}"`)).join("\t")}`,
52
+ ].join("\n") + "\r",
53
);
54
55
yield* fs.writeFileString(
@@ -51,6 +63,11 @@ describe("ssh config", () => {
63
[
64
["escaped", "escaped.example.com", "ssh-config"],
65
["quoted", "quoted.example.com", "ssh-config"],
66
+ ...unicodeFiles.map((_, index) => [
67
+ `unicode-${index}`,
68
+ `unicode-${index}.example.com`,
69
+ "ssh-config",
70
+ ]),
71
],
72
);
73
}).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
packages/ssh/src/config.ts
+4
-2
@@ -16,7 +16,9 @@ const NO_HOSTS: ReadonlyArray<string> = [] as const;
16
// escapes \\ \" \' and unquoted "\ ", and "#" starting a comment only at
17
// the start of a token. Invalid quoting leaves hostname resolution uncertain.
18
function parseSshConfigLine(line: string) {
19
- const match = /^\s*([^\s=]+)\s*=?\s*(.*)$/u.exec(line);
19
+ const match = /^[ \t\r]*([^ \t\r=]+)[ \t\r]*=?[ \t\r]*(.*)$/su.exec(
20
+ line.replace(/[ \t\r\f]+$/u, ""),
21
+ );
22
if (!match) {
23
return null;
24
}
@@ -44,7 +46,7 @@ function parseSshConfigLine(line: string) {
46
} else if (char === '"' || char === "'") {
47
quote = char;
48
token ??= "";
47
- } else if (/\s/u.test(char)) {
49
+ } else if (/[ \t]/u.test(char)) {
50
if (token !== null) {
51
args.push(token);
52
token = null;