Skip to content

Commit 8dd60f5

Browse files
patthoytspaulusmack
authored andcommitted
gitk: Quote tag names in event bindings to avoid problems with % chars
Tag names that contain a % character require quoting when used in event bindings or the name may be mis-recognised for percent substitution in the event script. Reported-by: Jonathan Nieder <[email protected]> Signed-off-by: Pat Thoyts <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 21ac8a8 commit 8dd60f5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

gitk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6301,6 +6301,7 @@ proc drawtags {id x xt y1} {
63016301
-width $lthickness -fill black -tags tag.$id]
63026302
$canv lower $t
63036303
foreach tag $marks x $xvals wid $wvals {
6304+
set tag_quoted [string map {% %%} $tag]
63046305
set xl [expr {$x + $delta}]
63056306
set xr [expr {$x + $delta + $wid + $lthickness}]
63066307
set font mainfont
@@ -6309,7 +6310,7 @@ proc drawtags {id x xt y1} {
63096310
set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \
63106311
$xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \
63116312
-width 1 -outline black -fill yellow -tags tag.$id]
6312-
$canv bind $t <1> [list showtag $tag 1]
6313+
$canv bind $t <1> [list showtag $tag_quoted 1]
63136314
set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]
63146315
} else {
63156316
# draw a head or other ref
@@ -6336,9 +6337,9 @@ proc drawtags {id x xt y1} {
63366337
set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \
63376338
-font $font -tags [list tag.$id text]]
63386339
if {$ntags >= 0} {
6339-
$canv bind $t <1> [list showtag $tag 1]
6340+
$canv bind $t <1> [list showtag $tag_quoted 1]
63406341
} elseif {$nheads >= 0} {
6341-
$canv bind $t $ctxbut [list headmenu %X %Y $id $tag]
6342+
$canv bind $t $ctxbut [list headmenu %X %Y $id $tag_quoted]
63426343
}
63436344
}
63446345
return $xt

0 commit comments

Comments
 (0)