Commit 5c3faa7
fix(hooks): a backslash-escaped quote must not end a double-quoted word in the Bash write guard (#10406)
An escaped \" inside a double-quoted word ended the quote, so everything after it
was re-read as bare shell. In a `node -e "..."` program that tail contains JS arrow
functions, whose ASCII > landed in redirection-operator position — and the guard then
named the following JS fragment as a write "target" and blocked a pure-read command.
A guard that names a concrete target is convincing, so the false positive trained
agents toward OS_ALLOW_MAIN_EDITS=1: the one outcome a write guard must never encourage.
Backslash now keeps its meaning inside "..." only before " \\ $ and a backtick, per
POSIX, in both the segmenter and the tokeniser; single quotes still take no escapes.
This narrows the block side only — no shape that was allowed becomes blocked.
Also pins the ASCII-only operator contract in the self-test: non-ASCII codepoints are
never operators or operator boundaries, with negative twins asserting a real ASCII
redirect in an otherwise-similar command still blocks.
Part of #10247
Claude-Session: https://claude.ai/code/session_019T1sSZbQTnLhrK9HhNdNiB
Co-authored-by: Claude <noreply@anthropic.com>1 parent cdc7eff commit 5c3faa7
2 files changed
Lines changed: 56 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
146 | 173 | | |
147 | 174 | | |
148 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
57 | 72 | | |
58 | 73 | | |
59 | 74 | | |
| |||
130 | 145 | | |
131 | 146 | | |
132 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
133 | 154 | | |
134 | 155 | | |
135 | 156 | | |
| |||
155 | 176 | | |
156 | 177 | | |
157 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
158 | 185 | | |
159 | 186 | | |
160 | 187 | | |
| |||
0 commit comments