diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-09-06 21:44:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-06 21:44:59 +0800 |
commit | 88e1c29df192df411c3d1721d32e311daaab4f09 (patch) | |
tree | 56462b86a0fc01f839f2abd4656a324cfe790158 /modules/context/repo.go | |
parent | c03d75fbd51174d0e7ffdbaf9e9e253438d06cf7 (diff) | |
download | gitea-88e1c29df192df411c3d1721d32e311daaab4f09.tar.gz gitea-88e1c29df192df411c3d1721d32e311daaab4f09.zip |
Fix Go 1.13 private repository go get issue (#8112)
* Fix Go 1.13 invalid import path creation
Signed-off-by: Rutger Broekhoff <rutger@viasalix.nl>
* Apply suggested changes from #8100
Signed-off-by: Rutger Broekhoff <rutger@viasalix.nl>
Diffstat (limited to 'modules/context/repo.go')
-rw-r--r-- | modules/context/repo.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go index 1499145f74..3ef726f2e8 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -201,10 +201,14 @@ func ComposeGoGetImport(owner, repo string) string { // .netrc file. func EarlyResponseForGoGetMeta(ctx *Context) { username := ctx.Params(":username") - reponame := ctx.Params(":reponame") + reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git") + if username == "" || reponame == "" { + ctx.PlainText(400, []byte("invalid repository path")) + return + } ctx.PlainText(200, []byte(com.Expand(`<meta name="go-import" content="{GoGetImport} git {CloneLink}">`, map[string]string{ - "GoGetImport": ComposeGoGetImport(username, strings.TrimSuffix(reponame, ".git")), + "GoGetImport": ComposeGoGetImport(username, reponame), "CloneLink": models.ComposeHTTPSCloneURL(username, reponame), }))) } |