Fix shell injection in run_editor and add STDERR TTY check for --interactive#12
Merged
hahwul merged 2 commits intoMay 27, 2026
Conversation
…ractive - Avoid shell invocation in run_editor by parsing editor into argv and passing path as a separate argument, eliminating quoting/injection risks. - Add STDERR.tty? check alongside STDIN/STDOUT in --interactive mode so the command won't appear to hang when STDERR is redirected.
Copilot
AI
changed the title
[WIP] Fix code based on review comments
Fix shell injection in run_editor and add STDERR TTY check for --interactive
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses two issues from code review:
run_editorshell injection (src/cjules/unidiff.cr):shell_escapedidn't correctly handle single quotes in POSIX shells due togsubinterpreting backslashes in the replacement string. Removed shell invocation entirely — editor command is now split into argv and the path is passed as a separate argument toProcess.run, eliminating both the escaping bug and injection risk.Incomplete TTY check (
src/cjules/commands/patch.cr):--interactiveonly validatedSTDIN.tty? && STDOUT.tty?, but prompts are written to STDERR. AddedSTDERR.tty?so the command errors out instead of silently hanging when STDERR is redirected.