Skip to content

Commit 0963684

Browse files
committed
test(hooks): pin the nested quoted substitution by its recall twin
The depth-2 nested allow case passed on the pre-fix hook by quote parity, so it discriminated nothing. Replace it with a nested shape whose real sed -i behind a separator is only seen when the helper reads a `$(` inside a string inside the substitution as one more nesting level. Claude-Session: https://claude.ai/code/session_01M82feuetLzrCiBz41BJb7L Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5295de1 commit 0963684

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎.claude/hooks/guard-main-checkout-bash.selftest.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ CWD="$MAIN"
312312
expect allow 'echo "a $(curl -d "{\"c\":\"x > 1\"}" http://h)"'
313313
expect allow "echo \"a \$(curl -d '{\"c\":\"x > 1\"}' http://h)\""
314314
expect allow 'echo "a `curl -d "{\"c\":\"x > 1\"}" http://h`"' # the backtick spelling
315-
expect allow 'echo "$(echo "$(echo "x > 1")")"' # nested
316315
# Recall is untouched: a real write beside a quoted substitution still blocks — in the same
317316
# command, behind a separator, and inside a sed -i script — and so does the card's control.
318317
expect block 'echo hi > out.txt'
@@ -322,6 +321,7 @@ expect block 'sed -i "s/a/$(date +%F)/" pkg/x.ts'
322321
# The fail-OPEN mirror: one `"` in the body used to leave the outer string hanging, so the
323322
# separator behind it went inert and the real write rode through as text.
324323
expect block "echo \"\$(printf '\"')\" ; sed -i s/a/b/ pkg/x.ts"
324+
expect block "echo \"\$(echo \"\$(printf '\"')\")\" ; sed -i s/a/b/ pkg/x.ts" # nested
325325
# The heredoc scan reads the body the same way: the ` #` inside it is no comment, so the
326326
# introducer behind it is found and the body stays prose.
327327
expect allow "$(printf 'echo "$(echo " #")" <<EOF\nsed -i s/a/b/ pkg/x.ts\nEOF\n')"

0 commit comments

Comments
 (0)