summaryrefslogtreecommitdiffstats
path: root/cmd/serv.go
diff options
context:
space:
mode:
authorJohn Olheiser <42128690+jolheiser@users.noreply.github.com>2020-02-05 08:50:06 -0600
committerGitHub <noreply@github.com>2020-02-05 15:50:06 +0100
commit2cd2614eaa40bc25880431f6ea56f9c47a938508 (patch)
tree7dee72ab0095e5d050d5a30f25937796f31d51aa /cmd/serv.go
parent0129e76ef5bdd6af30207ce7d99bdbe70c108d18 (diff)
downloadgitea-2cd2614eaa40bc25880431f6ea56f9c47a938508.tar.gz
gitea-2cd2614eaa40bc25880431f6ea56f9c47a938508.zip
Fix push-create SSH bugs (#10145) (#10151)
* Attempt to fix push-create SSH bugs Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix binding Signed-off-by: jolheiser <john.olheiser@gmail.com> * Invalid ctx Signed-off-by: jolheiser <john.olheiser@gmail.com>
Diffstat (limited to 'cmd/serv.go')
-rw-r--r--cmd/serv.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd/serv.go b/cmd/serv.go
index 8ffe9b3a4f..fa1e033391 100644
--- a/cmd/serv.go
+++ b/cmd/serv.go
@@ -12,6 +12,7 @@ import (
"net/url"
"os"
"os/exec"
+ "regexp"
"strconv"
"strings"
"time"
@@ -72,6 +73,7 @@ var (
"git-receive-pack": models.AccessModeWrite,
lfsAuthenticateVerb: models.AccessModeNone,
}
+ alphaDashDotPattern = regexp.MustCompile(`[^\w-\.]`)
)
func fail(userMessage, logMessage string, args ...interface{}) {
@@ -147,6 +149,10 @@ func runServ(c *cli.Context) error {
username := strings.ToLower(rr[0])
reponame := strings.ToLower(strings.TrimSuffix(rr[1], ".git"))
+ if alphaDashDotPattern.MatchString(reponame) {
+ fail("Invalid repo name", "Invalid repo name: %s", reponame)
+ }
+
if setting.EnablePprof || c.Bool("enable-pprof") {
if err := os.MkdirAll(setting.PprofDataPath, os.ModePerm); err != nil {
fail("Error while trying to create PPROF_DATA_PATH", "Error while trying to create PPROF_DATA_PATH: %v", err)