diff options
| author | Kornel <kornel@geekhood.net> | 2021-05-30 17:01:02 +0100 |
|---|---|---|
| committer | Kornel <kornel@cloudflare.com> | 2021-07-09 14:09:48 +0100 |
| commit | d868da7796bfb96e87e09afc4e8338911b5f99b3 (patch) | |
| tree | 0d3c864b3127ed8f8a5c4a6cc42401064b915b4d /library/std/src/sys/windows/process | |
| parent | fcd5cecdcf50865df7838d734dfa5aeaa1f9c81e (diff) | |
| download | rust-d868da7796bfb96e87e09afc4e8338911b5f99b3.tar.gz rust-d868da7796bfb96e87e09afc4e8338911b5f99b3.zip | |
Unescaped command-line arguments for Windows
Fixes #29494
Diffstat (limited to 'library/std/src/sys/windows/process')
| -rw-r--r-- | library/std/src/sys/windows/process/tests.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/library/std/src/sys/windows/process/tests.rs b/library/std/src/sys/windows/process/tests.rs index 331bc9db3b1..3b65856dcac 100644 --- a/library/std/src/sys/windows/process/tests.rs +++ b/library/std/src/sys/windows/process/tests.rs @@ -1,14 +1,35 @@ use super::make_command_line; +use super::Arg; use crate::env; use crate::ffi::{OsStr, OsString}; use crate::process::Command; #[test] +fn test_raw_args() { + let command_line = &make_command_line( + OsStr::new("quoted exe"), + &[ + Arg::Regular(OsString::from("quote me")), + Arg::Raw(OsString::from("quote me *not*")), + Arg::Raw(OsString::from("\t\\")), + Arg::Raw(OsString::from("internal \\\"backslash-\"quote")), + Arg::Regular(OsString::from("optional-quotes")), + ], + false, + ) + .unwrap(); + assert_eq!( + String::from_utf16(command_line).unwrap(), + "\"quoted exe\" \"quote me\" quote me *not* \t\\ internal \\\"backslash-\"quote optional-quotes" + ); +} + +#[test] fn test_make_command_line() { fn test_wrapper(prog: &str, args: &[&str], force_quotes: bool) -> String { let command_line = &make_command_line( OsStr::new(prog), - &args.iter().map(|a| OsString::from(a)).collect::<Vec<OsString>>(), + &args.iter().map(|a| Arg::Regular(OsString::from(a))).collect::<Vec<_>>(), force_quotes, ) .unwrap(); |
