Skip to content

Commit 026c397

Browse files
j6tttaylorr
authored andcommitted
gitk: sanitize 'open' arguments: command pipeline
As in the earlier commits, introduce a function that constructs a pipeline of commands after sanitizing the arguments. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 79a3ef5 commit 026c397

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

gitk

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ proc safe_open_command_redirect {cmd redir} {
8282
open |[concat $cmd $redir] r
8383
}
8484

85+
# opens a pipeline with several commands for reading
86+
# cmds is a list of lists, each of which specifies a command and its arguments
87+
# calls `open` and returns the file id
88+
proc safe_open_pipeline {cmds} {
89+
set cmd {}
90+
foreach subcmd $cmds {
91+
set cmd [concat $cmd | [make_arglist_safe $subcmd]]
92+
}
93+
open $cmd r
94+
}
95+
8596
# End exec/open wrappers
8697

8798
proc hasworktree {} {
@@ -3970,14 +3981,14 @@ proc show_line_source {} {
39703981
set blamefile [file join $cdup $flist_menu_file]
39713982
if {$from_index ne {}} {
39723983
set blameargs [list \
3973-
| git cat-file blob $from_index \
3974-
| git blame -p -L$line,+1 --contents - -- $blamefile]
3984+
[list git cat-file blob $from_index] \
3985+
[list git blame -p -L$line,+1 --contents - -- $blamefile]]
39753986
} else {
39763987
set blameargs [list \
3977-
| git blame -p -L$line,+1 $id -- $blamefile]
3988+
[list git blame -p -L$line,+1 $id -- $blamefile]]
39783989
}
39793990
if {[catch {
3980-
set f [open $blameargs r]
3991+
set f [safe_open_pipeline $blameargs]
39813992
} err]} {
39823993
error_popup [mc "Couldn't start git blame: %s" $err]
39833994
return

0 commit comments

Comments
 (0)