diff options
author | rabite <rabite@posteo.de> | 2019-06-16 12:33:23 +0200 |
---|---|---|
committer | rabite <rabite@posteo.de> | 2019-06-16 12:33:23 +0200 |
commit | 8f5ad6b3c947fa058d34a749135e0cdcfd87304b (patch) | |
tree | c6e90966a1640a511cfc7dd416fef4e72d68bc28 /src | |
parent | 4a40754c4a18392edfa7ce0e0f9a1a33bb0d6fde (diff) |
fix potentially nasty bug with quotes in file names
Diffstat (limited to 'src')
-rw-r--r-- | src/proclist.rs | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/proclist.rs b/src/proclist.rs index 7af7670..05541bf 100644 --- a/src/proclist.rs +++ b/src/proclist.rs @@ -61,12 +61,14 @@ impl Cmd { .take() .unwrap() .iter() - .map(|file| file.strip_prefix(&self.cwd).into_os_string()) + .map(|file| file.strip_prefix(&self.cwd) + .into_os_string() + .escape_single_quote()) .collect::<Vec<OsString>>(); cmd.iter() - .map(|part| part.splice_quoted(&cwd_pat, - cwd_files.clone())) + .map(|part| part.splice_quoted_single(&cwd_pat, + cwd_files.clone())) .flatten().collect() } @@ -80,12 +82,14 @@ impl Cmd { .fold(cmd, |cmd, (i, tab_files)| { let tab_files_pat = OsString::from(format!("${}s", i)); let tab_file_paths = tab_files.iter() - .map(|file| file.strip_prefix(&self.cwd).into_os_string()) + .map(|file| file.strip_prefix(&self.cwd) + .into_os_string() + .escape_single_quote()) .collect::<Vec<OsString>>(); cmd.iter().map(|part| { - part.splice_quoted(&tab_files_pat, - tab_file_paths.clone()) + part.splice_quoted_single(&tab_files_pat, + tab_file_paths.clone()) }).flatten().collect() }) } @@ -99,11 +103,13 @@ impl Cmd { .enumerate() .fold(cmd, |cmd, (i, tab_path)| { let tab_path_pat = OsString::from(format!("${}", i)); - let tab_path = tab_path.strip_prefix(&self.cwd).into_os_string(); + let tab_path = tab_path.strip_prefix(&self.cwd) + .into_os_string() + .escape_single_quote(); cmd.iter().map(|part| { - part.splice_quoted(&tab_path_pat, - vec![tab_path.clone()]) + part.splice_quoted_single(&tab_path_pat, + vec![tab_path.clone()]) }).flatten().collect() }) } |