@matheusbsbs / matheus-bagliano / commits / 8dd60f5401
Fork 0

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>

Pat Thoyts committed Mar 1, 2011 at 23:50 UTC 8dd60f5401c6ccfb69de5e8f76c55fa9e92edae5
1 file changed +4 -3
gitk
+4 -3
@@ -6301,6 +6301,7 @@ proc drawtags {id x xt y1} {
6301 -width $lthickness -fill black -tags tag.$id]
6302 $canv lower $t
6303 foreach tag $marks x $xvals wid $wvals {
6304 + set tag_quoted [string map {% %%} $tag]
6305 set xl [expr {$x + $delta}]
6306 set xr [expr {$x + $delta + $wid + $lthickness}]
6307 set font mainfont
@@ -6309,7 +6310,7 @@ proc drawtags {id x xt y1} {
6310 set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \
6311 $xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \
6312 -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]
6314 set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]
6315 } else {
6316 # draw a head or other ref
@@ -6336,9 +6337,9 @@ proc drawtags {id x xt y1} {
6337 set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \
6338 -font $font -tags [list tag.$id text]]
6339 if {$ntags >= 0} {
6339 - $canv bind $t <1> [list showtag $tag 1]
6340 + $canv bind $t <1> [list showtag $tag_quoted 1]
6341 } 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]
6343 }
6344 }
6345 return $xt