fix(bash): treat background & as a command separator in allowlist mode (S1)

This commit is contained in:
sausheong committed 2026-06-13 16:23:51 +08:00
1 parent 34435736c5
commit a5f21d3a2c
2 files changed
+41 -4

No files matched your search

+6 -4
View File
@@ -132,10 +132,12 @@ func extractCommands(cmd string) []string {
// Find the earliest operator
minIdx := len(remaining)
opLen := 0
for _, op := range []string{"&&", "||", "|", ";"} {
if idx := strings.Index(remaining, op); idx != -1 && idx < minIdx {
minIdx = idx
opLen = len(op)
for _, op := range []string{"&&", "||", "|", ";", "&"} {
if idx := strings.Index(remaining, op); idx != -1 {
if idx < minIdx || (idx == minIdx && len(op) > opLen) {
minIdx = idx
opLen = len(op)
}
}
}