Repository navigation
Conversation
argPath in the bash branch only ran unquote() on raw args, which is a no-op for unquoted words with backslash-escaped chars (`/tmp/my\ project/x` keeps the literal backslash). The resolved path then literalises the backslash and path.relative() reports it as outside the project root when the project itself contains spaces, so the tool wrongly asks for external_directory permission (or hard-denies under a "*": "deny" agent rule). Strip backslash-escape sequences after unquote() so escaped chars collapse before path.resolve. PowerShell already handles this via expand(), so the fix is scoped to the bash branch. Closes anomalyco#49671
|
The following comment was made by an LLM, it may be inaccurate: |
|
Gentle nudge on this one — it's been open for a week with green checks and no review yet. The fix is small (one unescape pass in the bash path + one regression test), and the original misfire only bites when the project root itself contains a space. Happy to rebase or adjust if anything's off. |
|
A backslash-escaped space in a bash path arg is left escaped, so an in-project path whose root contains a space is treated as external. Head Fork leaf kvnloo#199 recorded fail→pass on That locks the unescape pass for bash path args. It does not change non-path shell parsing. |
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
Issue for this PR
Closes #49671
Type of change
What does this PR do?
The shell tool's bash branch only
unquote()s raw args, which is a no-op for unquoted words with backslash-escaped characters (/tmp/my\ project/xkeeps the\). SoresolvePathgets the literal string,containsPathmisses, and the path looks "external" — triggering theexternal_directoryprompt and, under a"*": denyagent rule, hard-denying the command.Adds an unescape pass (
\X→X) afterunquote()in the bash branch ofargPathso escaped characters collapse beforepath.resolve. The PowerShell branch is unchanged (itsexpand()chain already strips them).How did you verify your code works?
test/tool/shell.test.tsregression test: project root itself contains a space, innercat <root>/x.txtuses\escaping → assertsexternal_directoryis not triggered, exit 0, output contains "ok"shell.test.ts24/24 pass (23 baseline + 1 regression)bun run typecheckcleanChecklist