The best way to control Claude Code, Codex and more from any computer or phone
fix(shared): preserve escaped quotes in launch arguments (#19525)
Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com>
Simone committed
Oct 18, 2026 at 21:24 UTC
b656dd7da4d0ddd270ead7e8628bdf15ba0a1dad
3 files changed
+38
-1
apps/server/src/provider/codexLaunchArgs.test.ts
+14
@@ -29,6 +29,13 @@ describe("resolveCodexLaunchArgs", () => {
29
});
30
31
describe("codexAppServerArgs", () => {
32
+ it("preserves escaped TOML quotes in config values", () => {
33
+ NodeAssert.deepStrictEqual(
34
+ codexAppServerArgs(String.raw`--config model=\"gpt-6.1-sol\" --strict-config`),
35
+ ["app-server", "--config", 'model="gpt-6.1-sol"', "--strict-config"],
36
+ );
37
+ });
38
+
39
it("returns the app-server command for empty launch args", () => {
40
NodeAssert.deepStrictEqual(codexAppServerArgs(""), ["app-server"]);
41
});
@@ -44,6 +51,13 @@ describe("codexAppServerArgs", () => {
51
});
52
53
describe("codexExecLaunchArgs", () => {
54
+ it("preserves escaped TOML quotes in config values", () => {
55
+ NodeAssert.deepStrictEqual(
56
+ codexExecLaunchArgs(String.raw`--config model=\"gpt-6.1-sol\" --strict-config`),
57
+ ["--config", 'model="gpt-6.1-sol"', "--strict-config"],
58
+ );
59
+ });
60
+
61
it("keeps shared codex flags and omits app-server-only flags", () => {
62
NodeAssert.deepStrictEqual(
63
codexExecLaunchArgs('--strict-config --enable foo --listen off --config model="gpt 5"'),
packages/shared/src/cliArgs.test.ts
+23
@@ -3,6 +3,22 @@ import { describe, expect, it } from "vite-plus/test";
3
import { parseCliArgs, tokenizeCliArgs } from "./cliArgs.ts";
4
5
describe("tokenizeCliArgs", () => {
6
+ it("preserves escaped double quotes outside quoted values", () => {
7
+ expect(tokenizeCliArgs(String.raw`--config model=\"gpt-6.1-sol\" --strict-config`)).toEqual([
8
+ "--config",
9
+ 'model="gpt-6.1-sol"',
10
+ "--strict-config",
11
+ ]);
12
+ });
13
+
14
+ it("preserves escaped single quotes outside quoted values", () => {
15
+ expect(tokenizeCliArgs(String.raw`--append-system-prompt don\'t --verbose`)).toEqual([
16
+ "--append-system-prompt",
17
+ "don't",
18
+ "--verbose",
19
+ ]);
20
+ });
21
+
22
it("preserves quoted values and escaped spaces", () => {
23
expect(
24
tokenizeCliArgs(
@@ -24,6 +40,13 @@ describe("tokenizeCliArgs", () => {
40
});
41
42
describe("parseCliArgs", () => {
43
+ it("keeps escaped apostrophes in flag values without consuming the next flag", () => {
44
+ expect(parseCliArgs(String.raw`--append-system-prompt don\'t --verbose`)).toEqual({
45
+ flags: { "append-system-prompt": "don't", verbose: null },
46
+ positionals: [],
47
+ });
48
+ });
49
+
50
it("returns empty result for empty string", () => {
51
expect(parseCliArgs("")).toEqual({ flags: {}, positionals: [] });
52
});
packages/shared/src/cliArgs.ts
+1
-1
@@ -49,7 +49,7 @@ export function tokenizeCliArgs(args?: string): ReadonlyArray<string> {
49
}
50
} else if (char === "\\") {
51
const next = input[index + 1];
52
- if (next !== undefined && /\s/.test(next)) {
52
+ if (next !== undefined && /[\s'"]/.test(next)) {
53
current += next;
54
index++;
55
} else {