summaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2023-07-14 06:27:15 -0400
committerGitHub <noreply@github.com>2023-07-14 10:27:15 +0000
commit45b1f4dd3ba898decbc3472b78bac081e6833cca (patch)
tree14eab372ee2ece4d98f72a4f2d238656fba04a19 /routers/api
parent026e745b9e3737655189b4c351b43133574235dd (diff)
downloadgitea-45b1f4dd3ba898decbc3472b78bac081e6833cca.tar.gz
gitea-45b1f4dd3ba898decbc3472b78bac081e6833cca.zip
Add support for different Maven POM encoding (#25873) (#25890)
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>
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/packages/maven/maven.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/routers/api/packages/maven/maven.go b/routers/api/packages/maven/maven.go
index e28438f9ba..b2f55e03eb 100644
--- a/routers/api/packages/maven/maven.go
+++ b/routers/api/packages/maven/maven.go
@@ -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 {