Skip to content

Commit 4eed4db

Browse files
committed
extend bracket-scan regex to match [::exec ls] so namespace-qualified commands are not exempt
1 parent 618233d commit 4eed4db

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

typescript/__tests__/config/command_whitelist.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ describe("isQueryCommand", () => {
218218
expect(isQueryCommand("set x [exec ls]")).toEqual([false, "exec"]);
219219
});
220220

221+
it("bracket: blocks set x [::exec ls] with namespace-qualified command", () => {
222+
expect(isQueryCommand("set x [::exec ls]")).toEqual([false, "exec"]);
223+
});
224+
221225
it("bracket: blocks expr {[exec ls]} via bracket scan (finding 2)", () => {
222226
expect(isQueryCommand("expr {[exec ls]}")).toEqual([false, "exec"]);
223227
});

typescript/src/config/command_whitelist.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ function* iterVerbs(command: string): Generator<string> {
210210
yield verb;
211211
}
212212
}
213-
for (const match of command.matchAll(/\[(\w+)/g)) {
213+
for (const match of command.matchAll(/\[\s*(?::+)?(\w+)/g)) {
214214
yield match[1]!;
215215
}
216216
}

0 commit comments

Comments
 (0)