-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: strip comment lines from claudeArgs before shell-quote parsing #995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -58,6 +58,18 @@ describe("shell-quote parseShellArgs", () => { | |||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| test("should not swallow args after # comment lines", () => { | ||||||||||||||||||||||||||||
| // Regression test for https://github.com/anthropics/claude-code-action/issues/802 | ||||||||||||||||||||||||||||
| // shell-quote treats '#' as a shell comment, dropping all subsequent content | ||||||||||||||||||||||||||||
| const input = `--model 'claude-haiku-4-5'\n# This is a comment\n--allowed-tools 'mcp__github__create_comment'`; | ||||||||||||||||||||||||||||
| const result = parseShellArgs(input).filter( | ||||||||||||||||||||||||||||
| (arg) => typeof arg === "string", | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| // Without the fix, --allowed-tools would be swallowed by shell-quote | ||||||||||||||||||||||||||||
| // This test documents the raw shell-quote behavior (it WILL fail with shell-quote alone) | ||||||||||||||||||||||||||||
| // The actual fix is in parseClaudeArgsToExtraArgs which strips comment lines before parsing | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| const result = parseShellArgs(input).filter( | |
| (arg) => typeof arg === "string", | |
| ); | |
| // Without the fix, --allowed-tools would be swallowed by shell-quote | |
| // This test documents the raw shell-quote behavior (it WILL fail with shell-quote alone) | |
| // The actual fix is in parseClaudeArgsToExtraArgs which strips comment lines before parsing | |
| const result = parseShellArgs(input); | |
| const filtered = result.filter((arg) => typeof arg === "string"); | |
| // Without the fix, --allowed-tools would be swallowed by shell-quote | |
| // This test documents the raw shell-quote behavior (it WILL fail with shell-quote alone) | |
| // The actual fix is in parseClaudeArgsToExtraArgs which strips comment lines before parsing | |
| // Here we assert the raw shell-quote behavior: it drops args after the comment line. | |
| expect(filtered).toEqual(["--model", "claude-haiku-4-5"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line-based sanitization removes any line whose trimmed form starts with
#regardless of whether that line occurs inside a quoted multi-line argument (e.g., a multi-line--system-prompt "..."that contains Markdown headings). That would change the value passed through to the CLI. Consider making comment stripping quote-aware, or restricting it to comment lines that are definitely outside of any open quotes.