Skip to content

Commit 015d1db

Browse files
committed
test(agents): cover C1 control chars in buildProviderReauthCommand
Add a focused regression case asserting that a provider id containing any C1 byte (0x80-0x9f), including the U+009B CSI introducer, is rejected so no reauthentication command with an embedded C1 escape is rendered, while a clean provider id still produces the expected command. Signed-off-by: lsr911 <[email protected]>
1 parent 6e43dd4 commit 015d1db

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/agents/failover-error.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,21 @@ describe("buildFailoverRemediationHint", () => {
14361436
expect(buildProviderReauthCommand("custom\nprovider")).toBeUndefined();
14371437
});
14381438

1439+
it("refuses C1 control characters (U+0080-U+009F) in provider ids", () => {
1440+
// U+009B is the CSI introducer, an alternative ANSI escape prefix (ESC [).
1441+
// Without the C1 range, buildProviderReauthCommand would emit a
1442+
// remediation command with the raw C1 byte embedded in the shell literal.
1443+
const CSI = String.fromCharCode(0x9b);
1444+
expect(buildProviderReauthCommand(`anthropic${CSI}[2J`)).toBeUndefined();
1445+
for (let code = 0x80; code <= 0x9f; code += 1) {
1446+
expect(buildProviderReauthCommand(`anthropic${String.fromCharCode(code)}`)).toBeUndefined();
1447+
}
1448+
// A clean provider id is still accepted.
1449+
expect(buildProviderReauthCommand("anthropic")).toBe(
1450+
"openclaw models auth login --provider 'anthropic' --force",
1451+
);
1452+
});
1453+
14391454
it("wraps rendered provider commands in the standard CLI formatter", () => {
14401455
expect(buildProviderReauthCommand("anthropic", { OPENCLAW_PROFILE: "work" })).toBe(
14411456
"openclaw --profile work models auth login --provider 'anthropic' --force",

0 commit comments

Comments
 (0)