From: Matthias Lederhofer <matled@gmx.net>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH] gitweb: fix warnings in PATH_INFO code and add export_ok/strict_export
Date: Sun, 17 Sep 2006 15:29:48 +0200 [thread overview]
Message-ID: <20060917132948.GA976@moooo.ath.cx> (raw)
In-Reply-To: <7vodte4w9w.fsf@assigned-by-dhcp.cox.net>
---
Junio C Hamano <junkio@cox.net> wrote:
> Matthias Lederhofer <matled@gmx.net> writes:
> The PATHINFO stuff Martin Waitz did mucks with $project somewhat
> later than this part of the patch, possibly bypassing your
> checks. Could you check what's in 'master' to see if it is
> reasonable and if not fix it up please?
This patch replaces the other two warning fixes by Jakub and me. I've
put the whole thing in a sub-routine to keep the indentation level
low.
---
gitweb/gitweb.perl | 34 +++++++++++++++++++++-------------
1 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 497129a..0fb8638 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -189,9 +189,6 @@ do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
# version of the core git binary
our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
-# path to the current git repository
-our $git_dir;
-
$projects_list ||= $projectroot;
# ======================================================================
@@ -273,30 +270,41 @@ if (defined $searchtext) {
}
# now read PATH_INFO and use it as alternative to parameters
-our $path_info = $ENV{"PATH_INFO"};
-$path_info =~ s|^/||;
-$path_info =~ s|/$||;
-if (validate_input($path_info) && !defined $project) {
+sub evaluate_path_info {
+ return if defined $project;
+ my $path_info = $ENV{"PATH_INFO"};
+ return if !$path_info;
+ $path_info =~ s,(^/|/$),,gs;
+ $path_info = validate_input($path_info);
+ return if !$path_info;
$project = $path_info;
while ($project && !-e "$projectroot/$project/HEAD") {
$project =~ s,/*[^/]*$,,;
}
- if (defined $project) {
- $project = undef unless $project;
+ if (!$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/([^/]+)/(.+)$,) {
# we got "project.git/branch/filename"
$action ||= "blob_plain";
- $hash_base ||= $1;
- $file_name ||= $2;
+ $hash_base ||= validate_input($1);
+ $file_name ||= validate_input($2);
} elsif ($path_info =~ m,^$project/([^/]+)$,) {
# we got "project.git/branch"
$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
my %actions = (
--
1.4.2.1.ge767
next prev parent reply other threads:[~2006-09-17 13:30 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-16 19:27 [PATCH] gitweb: export-ok option Matthias Lederhofer
2006-09-16 19:40 ` Jakub Narebski
2006-09-16 20:33 ` Matthias Lederhofer
2006-09-16 20:37 ` Junio C Hamano
2006-09-16 19:44 ` Jakub Narebski
2006-09-16 21:43 ` [PATCH] gitweb: option 'strict export' Matthias Lederhofer
2006-09-16 22:30 ` [PATCH/current master] gitweb: do not use 'No such directory' error message Matthias Lederhofer
2006-09-16 22:31 ` [PATCH] gitweb: export options Matthias Lederhofer
2006-09-17 8:53 ` Junio C Hamano
2006-09-17 9:07 ` Matthias Lederhofer
2006-09-17 10:34 ` Junio C Hamano
2006-09-17 13:29 ` Matthias Lederhofer [this message]
2006-09-17 22:06 ` [PATCH] gitweb: fix warnings in PATH_INFO code and add export_ok/strict_export Junio C Hamano
2006-09-17 22:45 ` Jakub Narebski
2006-09-17 23:10 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060917132948.GA976@moooo.ath.cx \
--to=matled@gmx.net \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.