Skip to content

Commit e890ca9

Browse files
committed
test(cli): avoid control regex in approval safety check
1 parent f3ba353 commit e890ca9

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎src/cli/exec-approvals-cli.test.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,16 @@ describe("exec approvals CLI", () => {
327327
await runApprovalsCommand(["approvals", "get"]);
328328

329329
const output = defaultRuntime.log.mock.calls.map(([line]) => String(line ?? "")).join("\n");
330-
expect(output).not.toMatch(/[\u0007\u0008\u001b\u007f-\u009f]/u);
330+
const hasUnsafeControl = Array.from(output).some((char) => {
331+
const codePoint = char.codePointAt(0) ?? -1;
332+
return (
333+
codePoint === 0x07 ||
334+
codePoint === 0x08 ||
335+
codePoint === 0x1b ||
336+
(codePoint >= 0x7f && codePoint <= 0x9f)
337+
);
338+
});
339+
expect(hasUnsafeControl).toBe(false);
331340
expect(output).toContain("safered\\nnext\\trow\\rbackspace🦞");
332341

333342
defaultRuntime.writeJson.mockClear();

0 commit comments

Comments
 (0)