Skip to content

Both repository/contents API endpoints return 500 when a file contains a '%' sign #22843

Closed
@SolarBear

Description

@SolarBear

Description

This bug can be found in both GET endpoints: repository/contents as well as repository/contents/{filepath}

One can reproduce this bug fairly easily:

  1. Create a new repository. I called mine testpct.
  2. Clone the empty repository locally.
  3. Add a file whose name contains a '%' sign (e.g. hello%mother.txt)
  4. Add, commit and push this file.
  5. Using the Swagger interface or some other REST client, make a GET API call to http://MYHOST/api/v1/repos/USERNAME/testpct/contents
  6. This results in a 500 error whose body is simply
{
  "message": "",
  "url": "http://localhost:3000/api/swagger"
}
  1. Back to your filesystem, create a folder called folder.
  2. Move the the file you've created into that subfolder.
  3. Make a GET call to http://MYHOST/api/v1/repos/USERNAME/testpct/contents/folder
  4. This results in the same error as the previous one.

For the record, I am well aware that having special characters in file names is bad and, no, changing these file names is not possible. :)

Gitea Version

1.17.0, 1.18.3

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

https://gist.github.com/SolarBear/66fe09b5817c1aab74fa5292bebc894d

Screenshots

No response

Git Version

No response

Operating System

Windows 10

How are you running Gitea?

  • Our server is running 1.17.0, downloaded (IIRC) from the gitea.com Downloads page. The server is running as a Windows service.
  • Seeing our old-ish version had a bug, I tried it locally using version 1.18.3, installed from Scoop, running from Powershell.
  • Also replicated directly on https://try.gitea.io/

Database

SQLite

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions