Skip to content

Commit 78874d1

Browse files
rutgerbrflunny
authored andcommitted
Fix Go 1.13 invalid import path creation
Signed-off-by: Rutger Broekhoff <[email protected]>
1 parent c03d75f commit 78874d1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

modules/context/context.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,17 @@ func Contexter() macaron.Handler {
250250
if ctx.Query("go-get") == "1" {
251251
ownerName := c.Params(":username")
252252
repoName := c.Params(":reponame")
253+
if ownerName == "" || repoName == "" {
254+
_, _ = c.Write([]byte(`<!doctype html>
255+
<html>
256+
<body>
257+
invalid import path
258+
</body>
259+
</html>
260+
`))
261+
c.WriteHeader(404)
262+
return
263+
}
253264
branchName := "master"
254265

255266
repo, err := models.GetRepositoryByOwnerAndName(ownerName, repoName)

modules/context/repo.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ func ComposeGoGetImport(owner, repo string) string {
202202
func EarlyResponseForGoGetMeta(ctx *Context) {
203203
username := ctx.Params(":username")
204204
reponame := ctx.Params(":reponame")
205+
if username == "" || reponame == "" {
206+
ctx.PlainText(404, []byte("invalid repository path"))
207+
}
205208
ctx.PlainText(200, []byte(com.Expand(`<meta name="go-import" content="{GoGetImport} git {CloneLink}">`,
206209
map[string]string{
207210
"GoGetImport": ComposeGoGetImport(username, strings.TrimSuffix(reponame, ".git")),

0 commit comments

Comments
 (0)