Skip to content

Generic Registry: Fix a bug when downloading files with "+" symbol

Context

In Support directory structure in generic package ... (!153449 - merged), we allowed to download/upload files that their names contain /. That means users can upload directory structured files to the Generic Package Repository.

To do that, we are encoding the filename before saving it in the database. So, if the filename is path/to/file.txt, it will be encoded to path%2Fto%2Ffile.txt.

The problem is when we have a filename that contains + symbol. For example, a file named dummy+file.txt will be encoded to dummy%2Bfile.txt.

This caused the customers are unable to download any existing files that their names include + symbol.

Solution

We need to only encode filenames that have the directory structure. Other than that, we don't encode it.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. Create any dummy file with dummy content and name it dummy+file.txt.
  2. Publish it to a project:
curl --header "PRIVATE-TOKEN: <your_access_token>" \
     --upload-file path/to/dummy+file.txt \
     "http://gdk.test:3000/api/v4/projects/<project_id>/packages/generic/my_package/0.0.1/dummy+file.txt"
  1. Navigate to the UI page of the project's package registry. The file should be there with the correct name.
  2. Download the file from the UI or using the API: 200 OK
curl --header "PRIVATE-TOKEN: <your_access_token>" \
     "http://gdk.test:3000/api/v4/projects/<project_id>/packages/generic/my_package/0.0.1/dummy+file.txt"
  1. The file should be downloaded normally.

  2. Switch to master and try to download the file again: 404 Not found

Related to #463771 (closed)

Edited by Moaz Khalifa

Merge request reports