X-Git-Url: https://git.ladys.computer/Gitweb/blobdiff_plain/bed7568e4c40322b9b5a9c817d3f234fb446856554e8adaae72890d4ed098478..8f464726b9c1452de27d32cee93ddcbd81a47a3b31b317a7d78b595eed2d0f1a:/gitweb.cgi diff --git a/gitweb.cgi b/gitweb.cgi index 3a7e57b..b099a5c 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -# gitweb.pl - simple web interface to track changes in git repositories +# gitweb - simple web interface to track changes in git repositories # # (C) 2005, Kay Sievers # (C) 2005, Christian Gierke @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "206"; +my $version = "232"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -49,9 +49,10 @@ if (defined $action) { if ($action eq "git-logo.png") { git_logo(); exit; + } elsif ($action eq "opml") { + git_opml(); + exit; } -} else { - $action = "summary"; } my $project = $cgi->param('p'); @@ -73,7 +74,7 @@ if (defined $project) { die_error(undef, "No such project."); } $rss_link = ""; - $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$project/objects"; + $ENV{'GIT_DIR'} = "$projectroot/$project"; } else { git_project_list(); exit; @@ -92,9 +93,26 @@ if (defined $file_name) { } my $hash = $cgi->param('h'); -if (defined $hash && !($hash =~ m/^[0-9a-fA-F]{40}$/)) { - undef $hash; - die_error(undef, "Invalid hash parameter."); +if (defined $hash) { + if (!($hash =~ m/^[0-9a-fA-F]{40}$/)) { + if ($hash =~ m/(^|\/)(|\.|\.\.)($|\/)/) { + undef $hash; + die_error(undef, "Non-canonical hash parameter."); + } + if ($hash =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~\:\!]/) { + undef $hash; + die_error(undef, "Invalid character in hash parameter."); + } + # replace branch-name with hash + my $branchlist = git_read_refs("refs/heads"); + foreach my $entry (@$branchlist) { + my %branch = %$entry; + if ($branch{'name'} eq $hash) { + $hash = $branch{'id'}; + last; + } + } + } } my $hash_parent = $cgi->param('hp'); @@ -117,7 +135,6 @@ if (defined $page) { } } - my $searchtext = $cgi->param('s'); if (defined $searchtext) { if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) { @@ -127,7 +144,7 @@ if (defined $searchtext) { $searchtext = quotemeta $searchtext; } -if ($action eq "summary") { +if (!defined $action || $action eq "summary") { git_summary(); exit; } elsif ($action eq "branches") { @@ -198,6 +215,8 @@ sub git_header_html { + + $title $rss_link