Fix Go 1.13 private repository go get issue#8100
Conversation
Signed-off-by: Rutger Broekhoff <rutger@viasalix.nl>
| ownerName := c.Params(":username") | ||
| repoName := c.Params(":reponame") | ||
| if ownerName == "" || repoName == "" { | ||
| _, _ = c.Write([]byte(`<!doctype html> |
There was a problem hiding this comment.
if returned error, you should give a 500 I think.
There was a problem hiding this comment.
Why not see the problem the other way and simply ignore go-get params instead of erroring ?
if ctx.Query("go-get") == "1" && ownerName != "" && repoName != "" {
}
There was a problem hiding this comment.
This could be break down in two if obviously.
if ctx.Query("go-get") == "1"
ownerName := c.Params(":username")
repoName := c.Params(":reponame")
if ownerName != "" && repoName != "" {
... Do go-get work
}
}
There was a problem hiding this comment.
But else we still need return 404 but not continue the other work.
There was a problem hiding this comment.
Once ctx.Query("go-get") == "1" , it should return anyway here.
There was a problem hiding this comment.
I think a 400 should be returned because in this case the client has not provided adequate information for the server to provide an import URL from the its request.
There was a problem hiding this comment.
Line 58 in 85202d4
There was a problem hiding this comment.
Or perhaps in trimmedRepoName, such that this is not interfered with:
gitea/modules/context/context.go
Line 258 in bb609ca
There was a problem hiding this comment.
Why we should return an error ? For exemple github doesn't trigger an error on an profile if you use go-get param. Futhermore triggering an error from a supervision point could be misleading. I will not block as it need a quick fix.
| username := ctx.Params(":username") | ||
| reponame := ctx.Params(":reponame") | ||
| if username == "" || reponame == "" { | ||
| ctx.PlainText(404, []byte("invalid repository path")) |
| @@ -202,6 +202,9 @@ func ComposeGoGetImport(owner, repo string) string { | |||
| func EarlyResponseForGoGetMeta(ctx *Context) { | |||
There was a problem hiding this comment.
Same here we can check previously to calling this method and maybe pass username and reponame as args since they are already extracted and cleaned from context before calling:
Line 58 in 85202d4
There was a problem hiding this comment.
Would it not be preferable to add this for username as well in case only .git is appended to the Gitea instance URL?
There was a problem hiding this comment.
I guess not because it seems possible to have the suffix .git in a username or organization name.
Signed-off-by: Rutger Broekhoff <rutger@viasalix.nl>
techknowlogick
left a comment
There was a problem hiding this comment.
This should be sent to master branch first. I'm going to mark this as blocked so we don't merge this prematurely.
|
@rutgerbrf please send a PR to master also. |
Signed-off-by: Rutger Broekhoff <rutger@viasalix.nl>
* 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>
|
Since #8112 merged, I have removed the blocked label. @techknowlogick |
|
@techknowlogick it is been merged to master please approve |
Fixes #8095.