]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: do not misparse nonnumeric content tag files that contain a digit
authorJonathan Nieder <redacted>
Thu, 9 Jun 2011 07:08:57 +0000 (02:08 -0500)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:31 +0000 (00:51 -0400)
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index cd1a01959713e7501dac401d90613b6d2ddefdbfbae8cbf9d8f1c65038db4d71..60004e41465197ac74b1c0019009c26c5a802df238a17500efaa658fc4e37e9e 100755 (executable)
@@ -2645,7 +2645,7 @@ sub git_get_project_ctags {
                        close $ct;
 
                        (my $ctag = $tagfile) =~ s#.*/##;
                        close $ct;
 
                        (my $ctag = $tagfile) =~ s#.*/##;
-                       if ($val =~ /\d+/) {
+                       if ($val =~ /^\d+$/) {
                                $ctags->{$ctag} = $val;
                        } else {
                                $ctags->{$ctag} = 1;
                                $ctags->{$ctag} = $val;
                        } else {
                                $ctags->{$ctag} = 1;
This page took 0.327373 seconds and 4 git commands to generate.