diff options
author | John Olheiser <42128690+jolheiser@users.noreply.github.com> | 2020-02-05 03:40:35 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-05 10:40:35 +0100 |
commit | 95013fde60748c425eb910dcab5d1fdd1c89ae18 (patch) | |
tree | be73a9f9669fafe0788bd042a567cd43004da78f /cmd/serv.go | |
parent | 7dcd305424e1d3bfb1fc2b1eaa02ed47a83bddec (diff) | |
download | gitea-95013fde60748c425eb910dcab5d1fdd1c89ae18.tar.gz gitea-95013fde60748c425eb910dcab5d1fdd1c89ae18.zip |
Fix push-create SSH bugs (#10145)
* 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.go | 6 |
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) |