1
0
mirror of https://github.com/git/git.git synced 2024-10-21 08:08:16 +02:00

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 <jrnieder@gmail.com>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
Pat Thoyts 2011-03-01 23:50:50 +00:00 committed by Paul Mackerras
parent 21ac8a8d0b
commit 8dd60f5401

7
gitk

@ -6301,6 +6301,7 @@ proc drawtags {id x xt y1} {
-width $lthickness -fill black -tags tag.$id] -width $lthickness -fill black -tags tag.$id]
$canv lower $t $canv lower $t
foreach tag $marks x $xvals wid $wvals { foreach tag $marks x $xvals wid $wvals {
set tag_quoted [string map {% %%} $tag]
set xl [expr {$x + $delta}] set xl [expr {$x + $delta}]
set xr [expr {$x + $delta + $wid + $lthickness}] set xr [expr {$x + $delta + $wid + $lthickness}]
set font mainfont set font mainfont
@ -6309,7 +6310,7 @@ proc drawtags {id x xt y1} {
set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \ set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \
$xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \ $xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \
-width 1 -outline black -fill yellow -tags tag.$id] -width 1 -outline black -fill yellow -tags tag.$id]
$canv bind $t <1> [list showtag $tag 1] $canv bind $t <1> [list showtag $tag_quoted 1]
set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}] set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]
} else { } else {
# draw a head or other ref # draw a head or other ref
@ -6336,9 +6337,9 @@ proc drawtags {id x xt y1} {
set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \ set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \
-font $font -tags [list tag.$id text]] -font $font -tags [list tag.$id text]]
if {$ntags >= 0} { if {$ntags >= 0} {
$canv bind $t <1> [list showtag $tag 1] $canv bind $t <1> [list showtag $tag_quoted 1]
} elseif {$nheads >= 0} { } elseif {$nheads >= 0} {
$canv bind $t $ctxbut [list headmenu %X %Y $id $tag] $canv bind $t $ctxbut [list headmenu %X %Y $id $tag_quoted]
} }
} }
return $xt return $xt