From 009cf77982b4cb707010f1cf884b1c9ef22fafe7 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 1 Jul 2013 17:38:10 -0700 Subject: [PATCH] git-shell-verify: make leading/trailing '/' optional This means that if the repository url is: ssh://example.com/srv/git/example.git Then all of the following will be accepted: ssh://example.com/srv/git/example.git ssh://example.com/srv/git/example.git/ example.com:/srv/git/example.com example.com:srv/git/example.com example.com:/srv/git/example.com/ example.com:srv/git/example.com/ Previously the ones where the path part lacked a leading '/' and/or added a trailing '/' were not accepted. --- bin/git-shell-verify | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/git-shell-verify b/bin/git-shell-verify index 28e5611..2463593 100755 --- a/bin/git-shell-verify +++ b/bin/git-shell-verify @@ -26,7 +26,7 @@ webadmurl=@webadmurl@ # git-shell -c 'git-upload-archive dir' # git-shell -c 'git upload-archive dir' # -# where dir must start with $reporoot/ +# where dir must start with $reporoot/ but a leading/trailing '/' is optional if [ "$1" != "-c" ]; then echo 403 forbidden >&2 @@ -67,6 +67,19 @@ esac dir="${dir#\'}"; dir="${dir%\'}" +# add a missing leading / +case "$dir" in + /*) :;; + *) + dir="/$dir" +esac + +# remove a trailing / +case "$dir" in + *?/) + dir="${dir%/}" +esac + case "$dir" in "$reporoot/"*) :;; *) -- 2.11.4.GIT