From 2cfc81f230a06f629bc977baa66a149adcdbedec Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Fri, 15 Dec 2017 14:32:34 +0530 Subject: clean up previous patch on handling trailing slashes Actually this is a revert of the previous patch, combined with putting that logic where it belongs (and in the process doing it more cleanly) --- src/gitolite-shell | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/gitolite-shell b/src/gitolite-shell index 2f49479..072e0ff 100755 --- a/src/gitolite-shell +++ b/src/gitolite-shell @@ -109,10 +109,6 @@ sub main { # set up the repo and the attempted access my ( $verb, $repo ) = parse_soc(); # returns only for git commands - - # remove trailing slash, if any - $repo =~ s(/$)(); - Gitolite::Conf::Load::sanity($repo, $REPONAME_PATT); $ENV{GL_REPO} = $repo; my $aa = ( $verb =~ 'upload' ? 'R' : 'W' ); @@ -157,11 +153,19 @@ sub parse_soc { $soc ||= 'info'; my $git_commands = "git-upload-pack|git-receive-pack|git-upload-archive"; - if ( $soc =~ m(^($git_commands) '?/?(.*?)(?:\.git(\d)?)?'?$) ) { - my ( $verb, $repo, $trace_level ) = ( $1, $2, $3 ); - $ENV{D} = $trace_level if $trace_level; - _die "invalid repo name: '$repo'" if $repo !~ $REPONAME_PATT; + # simplify the regex; we'll handle all the reponame nuances later + if ( $soc =~ m(^($git_commands) '?/?(.*?)'?$) ) { + my ( $verb, $repo ) = ( $1, $2 ); trace( 2, "git command", $soc ); + + # clean up the repo name; first extract the trace level if supplied + # (and no, you can't have a trace level *and* a trailing slash). + $ENV{D} = $1 if $repo =~ s/\.git(\d)$//; + # and then the git-daemon-compatibility trailers + $repo =~ s(/$)(); + $repo =~ s(\.git$)(); + + _die "invalid repo name: '$repo'" if $repo !~ $REPONAME_PATT; return ( $verb, $repo ); } -- cgit v1.2.3-65-gdbad