Importing maven pom XML that's not UTF-8 encoded creates broken package #11214

Closed
opened 2025-11-02 09:31:03 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @TobiX on GitHub (Jul 12, 2023).

Description

When trying to mirror some old packages into a maven repository, we ran into an error when trying to upload ISO-8859-1-encoded pom XML files:

2023/07/10 16:54:52 ...kages/maven/maven.go:328:UploadPackageFile() [E] [64ac1bbc-4] Error parsing package metadata: xml: encoding "ISO-8859-1" declared but Decoder.CharsetReader is nil

While this will probably not happen with modern Maven versions, one might run into this problem when trying to cache/host old artifacts inside Gitea.

To Reproduce

  1. Get commons-jxpath-1.3 jar and pom from https://repo1.maven.org/maven2/commons-jxpath/commons-jxpath/1.3/
  2. Try to deploy to Gitea: mvn deploy:deploy-file -Dfile=commons-jxpath-1.3.jar -DrepositoryId=gitea -Durl=https://try.gitea.io/api/packages/encoding/maven -DpomFile=commons-jxpath-1.3.pom
  3. Receive 500 Internal Server Error (https://gist.github.com/TobiX/08ba809cb6d27df8aa5e85d0f3633b01)
  4. Repository view is now also broken: https://try.gitea.io/encoding/-/packages/maven/commons-jxpath-commons-jxpath/1.3

Gitea Version

1.19.4

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

grafik

Git Version

2.39.2

Operating System

Debian 12 (bookworm)

How are you running Gitea?

Database

PostgreSQL

Originally created by @TobiX on GitHub (Jul 12, 2023). ### Description When trying to mirror some old packages into a maven repository, we ran into an error when trying to upload ISO-8859-1-encoded pom XML files: ``` 2023/07/10 16:54:52 ...kages/maven/maven.go:328:UploadPackageFile() [E] [64ac1bbc-4] Error parsing package metadata: xml: encoding "ISO-8859-1" declared but Decoder.CharsetReader is nil ``` While this will probably not happen with modern Maven versions, one might run into this problem when trying to cache/host old artifacts inside Gitea. ## To Reproduce 1. Get commons-jxpath-1.3 jar and pom from https://repo1.maven.org/maven2/commons-jxpath/commons-jxpath/1.3/ 2. Try to deploy to Gitea: `mvn deploy:deploy-file -Dfile=commons-jxpath-1.3.jar -DrepositoryId=gitea -Durl=https://try.gitea.io/api/packages/encoding/maven -DpomFile=commons-jxpath-1.3.pom` 3. Receive `500 Internal Server Error` (https://gist.github.com/TobiX/08ba809cb6d27df8aa5e85d0f3633b01) 4. Repository view is now also broken: https://try.gitea.io/encoding/-/packages/maven/commons-jxpath-commons-jxpath/1.3 ### Gitea Version 1.19.4 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots ![grafik](https://github.com/go-gitea/gitea/assets/78534/479fcefc-9fd8-4b17-acd6-1eca9b600f00) ### Git Version 2.39.2 ### Operating System Debian 12 (bookworm) ### How are you running Gitea? - Downloaded from https://dl.gitea.com/gitea/1.19.4/ - Running with systemd, listening on a UNIX socket - Caddy as reverse proxy ### Database PostgreSQL
GiteaMirror added the topic/packagestype/bug labels 2025-11-02 09:31:03 -06:00
Author
Owner

@KN4CK3R commented on GitHub (Jul 13, 2023):

Thank you for the report. Fixed in #25873. To get rid of the 500 error you have to delete the package. Visit the package url + /settings to delete it or use the admin panel.

@KN4CK3R commented on GitHub (Jul 13, 2023): Thank you for the report. Fixed in #25873. To get rid of the 500 error you have to delete the package. Visit the package url + `/settings` to delete it or use the admin panel.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11214