Repository navigation
Description
actions-disable-guard reads a case pattern's | as a pipe. So ls | while read -r f; do case $f in .|..|""|*/*) continue ;; esac; done (with a made-word cue in the text) is refused: . reads as source fed by ls. That false refusal is from #1094 (the 11-30 comment, reading 1). #1504 tried to fix it, first by guessing pattern words before a ), then by tracking case WORD in .. esac in Lex. Both rounds of lens review found bypasses, so #1504 dropped the change, and case is read as on main.
A fix must make the harmless shape above pass, and keep case esac in y) :;; (esac) echo ok;; esac passing. It must also refuse every row below: main refuses each one, and an earlier #1504 head let each through (in each, f, c.txt or a holds a refused call, and u is a download):
From the ) ending a group or $(..) at a pattern:
x=$(case y in a) :;; esac; base64 -d f | bash)
( case y in a) :;; esac; curl -s u | bash )
x=$(case y in *) :;; esac; curl -s u | bash -s)
x=$(case y in a) :;; esac; curl -s u | python3)
case $f in a) :;;
curl x | bash) :;; esac
( case a in *) cat c.txt ;; esac | bash )
( case a in *) : ;; esac; cat c.txt case x in y | bash )
case WORD in esac, an empty case on one line (esac right after in ends it):
case x in esac|cat<f|bash
case x in esac|bash<f
x=$(case x in esac|cat<f|bash)
time case x in esac|bash<f (also `! case ..`, `if case ..; then :; fi`)
( cat f; case x in esac ) | bash
bash s.sh # s.sh: case "$1" in esac | bash < f
bash r.sh # r.sh: ( cat f; case "$1" in esac ) | bash
A pattern read as an a[..]= subscript (assigns_here while in a pattern list), and a [[ alternative leaving test mode on:
case "a[" in y) :;; a[) base64 -d a ]=1 | bash ;; esac
case x in y) :;;
a[) base64 -d a ]=1 | bash ;; esac
case "a[" in y) :;; (a[) base64 -d a ]=1 | bash ;; esac
case x in y) :;; [[|x) base64 -d a | bash ;; esac
case x in y) :;; [[|x) curl -s u | sh
esac
Related: Lex.close for $( does not know case (#1520). A fix that makes the lexer follow case should cover both. Also do not crash: case x in a|b\n:) raised IndexError in the #1504 attempt.
Tests (docs/internals/15_testing.md): one row per behaviour in the existing table, Pr1261Round2Test.test_gh_wrappers_pass (the harmless shape passes; a case is read as bash reads it; a pattern the guard cannot be sure of is refused). Check the rest of the list above by hand, and say in the PR that each refuses.
🤖 Generated with Claude Code
Activity