Add support for different Maven POM encoding (#25873)
Fixes #25853 - Maven POM files aren't always UTF-8 encoded. - Reject the upload of unparsable POM files
This commit is contained in:
parent
dc679fc9fa
commit
bd82d8974e
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)
|
||||
})
|
||||
}
|
||||
|
@ -320,7 +325,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