X-Git-Url: https://git.ladys.computer/Gitweb/blobdiff_plain/be731a362b6c8212efe520e1166c163e04ef7dbeb7c3c31feb971ad4847d29b0..c8781675934a3002fb72e8eead8230c06902a3561390dfaaf9a4a3016717f216:/gitweb.cgi diff --git a/gitweb.cgi b/gitweb.cgi index 8ec96cd..ffe4620 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 @@ -9,25 +9,26 @@ use strict; use warnings; -use CGI qw(:standard :escapeHTML); +use CGI qw(:standard :escapeHTML -nosticky); use CGI::Util qw(unescape); use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "152"; +my $version = "236"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; # absolute fs-path which will be prepended to the project path my $projectroot = "/pub/scm"; +$projectroot = "/home/kay/public_html/pub/scm"; # location of the git-core binaries my $gitbin = "/usr/bin"; # location for temporary files needed for diffs -my $gittmp = "/tmp/gitweb"; +my $git_temp = "/tmp/gitweb"; # target of the home link on top of all pages my $home_link = $my_uri; @@ -42,16 +43,17 @@ my $projects_list = "index/index.aux"; # input validation and dispatch my $action = $cgi->param('a'); if (defined $action) { - if ($action =~ m/[^0-9a-zA-Z\.\-]+/) { + if ($action =~ m/[^0-9a-zA-Z\.\-_]+/) { undef $action; die_error(undef, "Invalid action parameter."); } 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,8 +75,7 @@ if (defined $project) { die_error(undef, "No such project."); } $rss_link = ""; - $ENV{'GIT_OBJECT_DIRECTORY'} = "$projectroot/$project/objects"; - $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; + $ENV{'GIT_DIR'} = "$projectroot/$project"; } else { git_project_list(); exit; @@ -93,9 +94,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'); @@ -110,15 +128,24 @@ 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_\.\/\-\+\:\@ ]/) { + undef $searchtext; + die_error(undef, "Invalid search parameter."); } + $searchtext = quotemeta $searchtext; } -if ($action eq "summary") { +if (!defined $action || $action eq "summary") { git_summary(); exit; } elsif ($action eq "branches") { @@ -130,6 +157,9 @@ if ($action eq "summary") { } elsif ($action eq "blob") { git_blob(); exit; +} elsif ($action eq "blob_plain") { + git_blob_plain(); + exit; } elsif ($action eq "tree") { git_tree(); exit; @@ -145,12 +175,27 @@ if ($action eq "summary") { } elsif ($action eq "blobdiff") { git_blobdiff(); exit; +} elsif ($action eq "blobdiff_plain") { + git_blobdiff_plain(); + exit; } elsif ($action eq "commitdiff") { git_commitdiff(); exit; +} elsif ($action eq "commitdiff_plain") { + git_commitdiff_plain(); + exit; } elsif ($action eq "history") { git_history(); exit; +} elsif ($action eq "search") { + git_search(); + exit; +} elsif ($action eq "shortlog") { + git_shortlog(); + exit; +} elsif ($action eq "tag") { + git_tag(); + exit; } else { undef $action; die_error(undef, "Unknown action."); @@ -174,6 +219,8 @@ sub git_header_html { + + $title $rss_link