File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020//! ).unwrap();
2121//! ```
2222
23- #![ warn( missing_docs) ]
24- #![ warn( clippy:: pedantic) ]
25- #![ warn( clippy:: incompatible_msrv) ]
26- #![ allow( clippy:: default_trait_access, clippy:: struct_excessive_bools) ]
23+ #![ warn( clippy:: pedantic, missing_docs, clippy:: incompatible_msrv) ]
24+ #![ allow(
25+ clippy:: default_trait_access,
26+ clippy:: struct_excessive_bools,
27+ clippy:: collapsible_match
28+ ) ]
2729
2830#[ macro_use]
2931extern crate log;
@@ -91,8 +93,13 @@ fn shell_cmd(cmd: &str) -> Command {
9193}
9294#[ cfg( windows) ]
9395fn shell_cmd ( cmd : & str ) -> Command {
96+ use std:: os:: windows:: process:: CommandExt as _;
97+ // `cmd.exe` does not parse its command line using MSVC rules, so the default
98+ // `Command::arg` escaping (quoting/backslash-escaping) corrupts shell
99+ // metacharacters like `|`, `&`, `>` and embedded quotes. Pass the command
100+ // string verbatim via `raw_arg` so cmd.exe sees exactly what the user wrote.
94101 let mut c = Command :: new ( "cmd" ) ;
95- c. arg ( "/c" ) . arg ( cmd) ;
102+ c. arg ( "/c" ) . raw_arg ( cmd) ;
96103 c
97104}
98105
Original file line number Diff line number Diff line change @@ -18,8 +18,7 @@ fn middle_coord(size: Size, var: &str) -> Size {
1818 Size :: Percent ( p) => Size :: Percent ( 100u16 . saturating_sub ( p) / 2 ) ,
1919 Size :: Fixed ( cells) => Size :: Fixed (
2020 std:: env:: var ( var)
21- . map ( |s| s. parse ( ) . unwrap_or ( 80 ) )
22- . unwrap_or ( 80u16 )
21+ . map_or ( 80u16 , |s| s. parse ( ) . unwrap_or ( 80 ) )
2322 . saturating_sub ( cells)
2423 / 2 ,
2524 ) ,
@@ -32,8 +31,7 @@ fn align_end_coord(size: Size, var: &str) -> Size {
3231 Size :: Percent ( p) => Size :: Percent ( 100 - p) ,
3332 Size :: Fixed ( cols) => Size :: Fixed (
3433 std:: env:: var ( var)
35- . map ( |s| s. parse ( ) . unwrap_or ( 80 ) )
36- . unwrap_or ( 80u16 )
34+ . map_or ( 80u16 , |s| s. parse ( ) . unwrap_or ( 80 ) )
3735 . saturating_sub ( cols) ,
3836 ) ,
3937 Size :: Neg ( cells) => Size :: Fixed ( cells) ,
Original file line number Diff line number Diff line change @@ -93,6 +93,6 @@ impl Display for dyn SkimItem {
9393}
9494impl Debug for dyn SkimItem {
9595 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
96- f. write_fmt ( format_args ! ( "SkimItem {{ text: {} }}" , self . text( ) , ) )
96+ f. write_fmt ( format_args ! ( "SkimItem {{ text: {} }}" , self . text( ) ) )
9797 }
9898}
You can’t perform that action at this time.
0 commit comments