summaryrefslogtreecommitdiffstats
path: root/modules/packages/maven/metadata.go
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 /modules/packages/maven/metadata.go
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 'modules/packages/maven/metadata.go')
-rw-r--r--modules/packages/maven/metadata.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/packages/maven/metadata.go b/modules/packages/maven/metadata.go
index be057c8c07..42aa250718 100644
--- a/modules/packages/maven/metadata.go
+++ b/modules/packages/maven/metadata.go
@@ -8,6 +8,8 @@ import (
"io"
"code.gitea.io/gitea/modules/validation"
+
+ "golang.org/x/net/html/charset"
)
// Metadata represents the metadata of a Maven package
@@ -52,7 +54,10 @@ type pomStruct struct {
// ParsePackageMetaData parses the metadata of a pom file
func ParsePackageMetaData(r io.Reader) (*Metadata, error) {
var pom pomStruct
- if err := xml.NewDecoder(r).Decode(&pom); err != nil {
+
+ dec := xml.NewDecoder(r)
+ dec.CharsetReader = charset.NewReaderLabel
+ if err := dec.Decode(&pom); err != nil {
return nil, err
}