enketo icon indicating copy to clipboard operation
enketo copied to clipboard

Uploading a filename with a #, makes this file uneditable

Open MartijnR opened this issue 1 year ago • 3 comments

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

  1. Open a form with an image file input e.g. this one
  2. Upload an image with a # in its name like 'myimage#1.jpg'
  3. Submit the record
  4. Edit the record (by clicking the edit button in the server interface, e.g. Centro, KoBoToolbox)
  5. See that the image fails to load

Expected behavior I expect to see the image file I uploaded previously.

Screenshots Screenshot 2024-06-14 at 2 51 56 PM

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:

  1. 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 as http://example.com/myimage#1.jpg. This is because of the middleware used to decode the API request body.
  2. (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:
Screenshot 2024-07-08 at 11 11 28 AM

MartijnR avatar Jun 14 '24 18:06 MartijnR

I'd like to publish a release today or tomorrow. Any chance this might be close, @MartijnR?

lognaturel avatar Jul 11 '24 19:07 lognaturel

Ah great! It may not be so close, so probably best to proceed with the release without it.

MartijnR avatar Jul 11 '24 19:07 MartijnR

I'm unable to reproduce this with ODK Central. Here's the response I get when doing an edit which seems expected to me:

Screenshot 2024-09-10 at 10 10 29 AM

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?

lognaturel avatar Sep 10 '24 17:09 lognaturel