X-Git-Url: https://git.ladys.computer/Gitweb/blobdiff_plain/c231d930151058dc6d8eadc06ec787b0dd703874639b2052e7d2e76e547763b8..5ca6347a26ce3cd988a527f9624d3463e4850d568df6ea9b85d972fdd4bf4d5c:/gitweb.cgi diff --git a/gitweb.cgi b/gitweb.cgi index 528238b..0698b74 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 = "203"; +my $version = "234"; 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'); @@ -109,15 +127,14 @@ if (defined $hash_base && !($hash_base =~ m/^[0-9a-fA-F]{40}$/)) { die_error(undef, "Invalid parent hash parameter."); } -my $time_back = $cgi->param('t'); -if (defined $time_back) { - if ($time_back =~ m/^[^0-9]+$/) { - undef $time_back; - die_error(undef, "Invalid time parameter."); +my $page = $cgi->param('pg'); +if (defined $page) { + if ($page =~ m/^[^0-9]+$/) { + undef $page; + die_error(undef, "Invalid page parameter."); } } - 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