Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
sitaramc committed Dec 15, 2017
1 parent 3e0c51e commit 2cfc81f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/gitolite-shell
Expand Up @@ -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' );
Expand Down Expand Up @@ -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 );
}

Expand Down

0 comments on commit 2cfc81f

Please sign in to comment.