Repository navigation
fix(spawn): pass CWD to tmux split-window via -c flag #563
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 all commits
070bef5
c02b516
239a179
ccd43f7
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 |
|---|---|---|
|
|
@@ -502,7 +502,8 @@ async function launchTmuxSpawn(ctx: SpawnCtx): Promise<void> { | |
|
|
||
| let paneId: string; | ||
| try { | ||
| const splitCmd = `tmux split-window -d ${splitTarget} -P -F '#{pane_id}' ${ctx.fullCommand}`; | ||
| const cwdFlag = ctx.cwd ? `-c '${ctx.cwd}'` : ''; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Building Useful? React with 👍 / 👎. |
||
| const splitCmd = `tmux split-window -d ${splitTarget} ${cwdFlag} -P -F '#{pane_id}' ${ctx.fullCommand}`; | ||
| paneId = execSync(splitCmd, { encoding: 'utf-8' }).trim(); | ||
| } catch (err) { | ||
| console.error(`Failed to create tmux pane: ${err instanceof Error ? err.message : 'unknown error'}`); | ||
|
|
||
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
ctx.cwdvariable is used to construct a shell command without proper escaping, which can lead to a command injection vulnerability. Ifctx.cwdcontains special shell characters like a single quote, it can break the command or allow arbitrary code execution. Please escapectx.cwdto prevent this. A similar escaping pattern is used insrc/lib/tmux.ts.