Files
orca/src/main/claude-accounts/windows-command-invocation.test.ts
T
87c59dd27d fix(claude-accounts): quote resolved claude path for Windows shell spawn (#10237)
* fix(claude-accounts): quote resolved claude path for Windows shell spawn

runClaudeCommand spawns the resolved claude command with shell:true on
Windows, but spawn concatenates the command into the cmd.exe line without
quoting. When the CLI resolves to a path containing spaces (e.g.
C:\Users\First Last\AppData\Roaming\npm\claude.cmd), cmd.exe splits at the
first space and account add fails with:

  'C:\Users\First' is not recognized as an internal or external command

Quote the command the same way claude-pty.ts and quoteWindowsCmdArg
already do for other Windows spawns.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(claude-accounts): own Windows cmd invocation

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-07-23 17:44:43 -07:00

34 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { buildWindowsCommandInvocation } from './windows-command-invocation'
describe('buildWindowsCommandInvocation', () => {
it('preserves hostile-but-valid cmd path and argument characters', () => {
const invocation = buildWindowsCommandInvocation(
'C:\\Users\\space & ^ (paren) %PATH_TRAP% !bang! 한글\\claude.cmd',
['', 'two words', 'amp&ersand', 'caret^value', '(parentheses)', '%ARG_TRAP%', '한글-λ'],
'C:\\Windows\\System32\\cmd.exe'
)
expect(invocation).toEqual({
command: 'C:\\Windows\\System32\\cmd.exe',
args: [
'/d',
'/v:off',
'/s',
'/c',
'""C:\\Users\\space & ^ (paren) "^%"PATH_TRAP"^%" !bang! 한글\\claude.cmd" "" "two words" "amp&ersand" "caret^value" "(parentheses)" ""^%"ARG_TRAP"^%"" "한글-λ""'
],
windowsVerbatimArguments: true
})
})
it('rejects tokens that cmd.exe cannot preserve safely', () => {
expect(() => buildWindowsCommandInvocation('claude.cmd', ['line\nbreak'])).toThrow(
'cannot contain quotes or line breaks'
)
expect(() => buildWindowsCommandInvocation('claude.cmd', ['quoted"value'])).toThrow(
'cannot contain quotes or line breaks'
)
})
})