fix: return bad request on malformed packages upload input (#10954)
I noticed that the wrong content type in an `/upload` request can trigger a 500, and I'm guessing it is more appropriate to return 400 instead. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10954 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Roberto Vidal <roberto.vidal@ikumene.com> Co-committed-by: Roberto Vidal <roberto.vidal@ikumene.com>
This commit is contained in:
@@ -30,3 +30,7 @@ func (ctx *Context) UploadStream() (rd io.ReadCloser, needToClose bool, err erro
|
||||
}
|
||||
return ctx.Req.Body, false, nil
|
||||
}
|
||||
|
||||
func IsFormError(err error) bool {
|
||||
return err == http.ErrMissingFile || err == http.ErrMissingBoundary
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user