mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-28 12:00:01 +02:00
Backport #25873 by @KN4CK3R Fixes #25853 - Maven POM files aren't always UTF-8 encoded. - Reject the upload of unparsable POM files Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
This commit is contained in:
parent
026e745b9e
commit
45b1f4dd3b
3 changed files with 30 additions and 2 deletions
|
@ -49,6 +49,11 @@ var (
|
|||
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
// The maven client does not present the error message to the user. Log it for users with access to server logs.
|
||||
if status == http.StatusBadRequest || status == http.StatusInternalServerError {
|
||||
log.Error(message)
|
||||
}
|
||||
|
||||
ctx.PlainText(status, message)
|
||||
})
|
||||
}
|
||||
|
@ -326,7 +331,8 @@ func UploadPackageFile(ctx *context.Context) {
|
|||
var err error
|
||||
pvci.Metadata, err = maven_module.ParsePackageMetaData(buf)
|
||||
if err != nil {
|
||||
log.Error("Error parsing package metadata: %v", err)
|
||||
apiError(ctx, http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
if pvci.Metadata != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue