Files
codex/codex-rs/windows-sandbox-rs/src/cmd_script_tests.rs
T
malsamiri-oai 627b579219 Preserve script quotes in Windows sandbox cmd invocations (#60624)
## Why

CRT argument escaping adds literal backslashes before quotes in `cmd.exe /c` scripts, breaking quoted paths and executable names.

## What changed

Serialize single-script `cmd /c` invocations with `/s /c` and an outer quote pair, preserving the script's quotes. Share this handling across Windows sandbox process creation, ConPTY, and MXC execution requests.

## Testing

Add a regression test for `certutil -hashfile` with a quoted path containing spaces, and update the command-line test for a quoted PowerShell executable.

GitOrigin-RevId: 32b4b7b55f6af4dba206813eac150310f37ae1d4
2026-11-10 16:58:06 +00:00

20 lines
495 B
Rust

#![cfg(test)]
use super::cmd_script_command_line;
#[test]
fn preserves_quotes_in_the_hash_command() {
let argv = [
r"C:\Windows\System32\CMD.EXE",
"/C",
r#"certutil -hashfile "C:\New folder\long name.pftrace" SHA256"#,
]
.map(str::to_owned);
assert_eq!(
cmd_script_command_line(&argv).as_deref(),
Some(
r#""C:\Windows\System32\CMD.EXE" /s /c "certutil -hashfile "C:\New folder\long name.pftrace" SHA256""#
)
);
}