Artifacts preview of filenames with urlencoded characters gives 404 (not found)
Summary
When browsing CI job artifacts that can be previewed in the browser (.txt
, .json
, .log
, .html
), trying to preview any filename that contain special url encoded characters (spaces, etc) gives a "404 Not Found" http error instead of showing the file. (Even as the url seem to be correctly encoded)
Steps to reproduce
Create a CI job that saves artifacts with filenames containing spaces or any other characters that will be urlencoded:
test_html_preview:
script:
- echo Hello1 > "test 1.txt"
- echo Hello2 > "test_2.txt"
- echo Hello3 > "test{3.txt"
- echo Hello4 > "test#4.txt"
artifacts:
paths:
- '*.txt'
Let the job run, and "Browse" the resulting artifacts.
Of the above examples, preview only works for test_2.txt
.
Example Project
https://gitlab.com/cavatina/gitlab-test-artifacts-preview
Example job with artifacts containing escaped characters: https://gitlab.com/cavatina/gitlab-test-artifacts-preview/-/jobs/373553355/artifacts/browse
Example artifact test 1.txt
, gives 404 Not Found
:
https://cavatina.gitlab.io/-/gitlab-test-artifacts-preview/-/jobs/373553355/artifacts/test%201.txt
Example artifact test_2.txt
, displays correctly:
https://cavatina.gitlab.io/-/gitlab-test-artifacts-preview/-/jobs/373553355/artifacts/test_2.txt
What is the current bug behavior?
An artifact with url encoded characters in the filename gives "404 Not Found" error. For example: https://cavatina.gitlab.io/-/gitlab-test-artifacts-preview/-/jobs/373553355/artifacts/test%201.txt
Interestingly, a hash character is not escaped at all (See above job artifacts).
The same behaviour is exhibited both on public projects, and private projects with GitLab Pages access_control enabled.
What is the expected correct behavior?
The artifact should be previewed in the browser.
Output of checks
This bug happens on GitLab.com.
(And also on our self hosted GitLab instance; version 12.5.3 (225d2e5bb89))