gitweb: fix warnings in PATH_INFO code and add export_ok/strict_export

Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Matthias Lederhofer 2006-09-17 15:29:48 +02:00 committed by Junio C Hamano
parent 9c95fbf94f
commit 645927cec8

View File

@ -189,9 +189,6 @@ do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
# version of the core git binary # version of the core git binary
our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown"; our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
# path to the current git repository
our $git_dir;
$projects_list ||= $projectroot; $projects_list ||= $projectroot;
# ====================================================================== # ======================================================================
@ -273,30 +270,41 @@ if (defined $searchtext) {
} }
# now read PATH_INFO and use it as alternative to parameters # now read PATH_INFO and use it as alternative to parameters
our $path_info = $ENV{"PATH_INFO"}; sub evaluate_path_info {
$path_info =~ s|^/||; return if defined $project;
$path_info =~ s|/$||; my $path_info = $ENV{"PATH_INFO"};
if (validate_input($path_info) && !defined $project) { return if !$path_info;
$path_info =~ s,(^/|/$),,gs;
$path_info = validate_input($path_info);
return if !$path_info;
$project = $path_info; $project = $path_info;
while ($project && !-e "$projectroot/$project/HEAD") { while ($project && !-e "$projectroot/$project/HEAD") {
$project =~ s,/*[^/]*$,,; $project =~ s,/*[^/]*$,,;
} }
if (defined $project) { if (!$project ||
$project = undef unless $project; ($export_ok && !-e "$projectroot/$project/$export_ok") ||
($strict_export && !project_in_list($project))) {
undef $project;
return;
} }
# do not change any parameters if an action is given using the query string
return if $action;
if ($path_info =~ m,^$project/([^/]+)/(.+)$,) { if ($path_info =~ m,^$project/([^/]+)/(.+)$,) {
# we got "project.git/branch/filename" # we got "project.git/branch/filename"
$action ||= "blob_plain"; $action ||= "blob_plain";
$hash_base ||= $1; $hash_base ||= validate_input($1);
$file_name ||= $2; $file_name ||= validate_input($2);
} elsif ($path_info =~ m,^$project/([^/]+)$,) { } elsif ($path_info =~ m,^$project/([^/]+)$,) {
# we got "project.git/branch" # we got "project.git/branch"
$action ||= "shortlog"; $action ||= "shortlog";
$hash ||= $1; $hash ||= validate_input($1);
} }
} }
evaluate_path_info();
$git_dir = "$projectroot/$project"; # path to the current git repository
our $git_dir;
$git_dir = "$projectroot/$project" if $project;
# dispatch # dispatch
my %actions = ( my %actions = (