Skip to content

Commit 2c162b5

Browse files
jrngitster
authored andcommitted
gitweb: do not misparse nonnumeric content tag files that contain a digit
v1.7.6-rc0~27^2~4 (gitweb: Change the way "content tags" ('ctags') are handled, 2011-04-29) tried to make gitweb's tag cloud feature more intuitive for webmasters by checking whether the ctags/<label> under a project's .git dir contains a number (representing the strength of association to <label>) before treating it as one. With that change, after putting '$feature{'ctags'}{'default'} = [1];' in your $GITWEB_CONFIG, you could do echo Linux >.git/ctags/linux and gitweb would treat that as a request to tag the current repository with the Linux tag, instead of the previous behavior of writing an error page embedded in the projects list that triggers error messages from Chromium and Firefox about malformed XML. Unfortunately the pattern (\d+) used to match numbers is too loose, and the "XML declaration allowed only at the start of the document" error can still be experienced if you write "Linux-2.6" in place of "Linux" in the example above. Fix it by tightening the pattern to ^\d+$. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2cbd969 commit 2c162b5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

gitweb/gitweb.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2644,7 +2644,7 @@ sub git_get_project_ctags {
26442644
close $ct;
26452645

26462646
(my $ctag = $tagfile) =~ s#.*/##;
2647-
if ($val =~ /\d+/) {
2647+
if ($val =~ /^\d+$/) {
26482648
$ctags->{$ctag} = $val;
26492649
} else {
26502650
$ctags->{$ctag} = 1;

t/t9500-gitweb-standalone-no-errors.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,14 @@ test_expect_success \
644644
'ctags: search projects by non existent tag' \
645645
'gitweb_run "by_tag=non-existent"'
646646

647+
test_expect_success \
648+
'ctags: malformed tag weights' \
649+
'mkdir -p .git/ctags &&
650+
echo "not-a-number" > .git/ctags/nan &&
651+
echo "not-a-number-2" > .git/ctags/nan2 &&
652+
echo "0.1" >.git/ctags/floating-point &&
653+
gitweb_run'
654+
647655
# ----------------------------------------------------------------------
648656
# categories
649657

0 commit comments

Comments
 (0)