Uploading a filename with a #, makes this file uneditable
Describe the bug Uploading e.g. an image file with a hash in its filename, e.g. 'myimage#1.jpg' causes an issue when editing that record later. The uploaded image is not loaded/shown in the loaded record.
To Reproduce
- Open a form with an image file input e.g. this one
- Upload an image with a
#in its name like 'myimage#1.jpg' - Submit the record
- Edit the record (by clicking the edit button in the server interface, e.g. Centro, KoBoToolbox)
- See that the image fails to load
Expected behavior I expect to see the image file I uploaded previously.
Screenshots
Browser and OS (please complete the following information):
independent of browser and os
Additional context OpenClinica is working on a fix. They found a combination of 2 issues:
- The instance_attachment URL is not stored correctly in the redis database. If it was correctly provided in the API request (URL-encoded) e.g. like
http://example.com/myimage%231.jpg, it is stored ashttp://example.com/myimage#1.jpg. This is because of the middleware used to decode the API request body. - (after fixing 1) The media.js file (or more likely the transformer package), also seems to strip parts of the URL and filename when it is provided in the internal /instance request. See image below:
I'd like to publish a release today or tomorrow. Any chance this might be close, @MartijnR?
Ah great! It may not be so close, so probably best to proceed with the release without it.
I'm unable to reproduce this with ODK Central. Here's the response I get when doing an edit which seems expected to me:
This is for a file with filename Screenshot#2024-09-10 at 9.02.51 AM-9_54_48.png that Enketo backend ends up serving as media/get/1/uuid:13990ad5-dfac-496e-928b-fcf5e97de7af/Screenshot%232024-09-10%20at%209.02.51%E2%80%AFAM-10_6_8.png. It's served from Central as Screenshot%232024-09-10%20at%209.02.51%E2%80%AFAM-10_6_8.png.
What are you getting from your servers?