Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fallback for old browsers when using ?filename parameter #7648

Closed
auburnsummer opened this issue Sep 4, 2020 · 5 comments · Fixed by #7677
Closed

Add fallback for old browsers when using ?filename parameter #7648

auburnsummer opened this issue Sep 4, 2020 · 5 comments · Fixed by #7677
Assignees
Labels
effort/hours Estimated to take one or several hours exp/intermediate Prior experience is likely helpful kind/enhancement A net-new feature or improvement to an existing feature P4 Very low priority status/in-progress In progress topic/gateway Topic gateway

Comments

@auburnsummer
Copy link

When using the ?filename parameter, the IPFS gateway adds a Content-Disposition header that is RFC 5987 encoded.

For instance, if I passed ?filename=hello.zip IPFS gives this as the Content-Disposition:

content-disposition: inline; filename*=UTF-8''hello.zip

However, not all browsers/clients correctly support RFC 5987. This can lead to unexpected behaviour with the filename parameter seemingly being ignored or treated incorrectly.

The typical fallback is to provide both a filename and filename* in the Content-Disposition:

content-disposition: inline; filename="hello.zip"; filename*=UTF-8''hello.zip

It would be good if the IPFS gateway did this to increase compatibility.

I'm not super familiar with Go, but I could have a go at this?

@auburnsummer auburnsummer added the kind/enhancement A net-new feature or improvement to an existing feature label Sep 4, 2020
@lidel lidel added need/analysis Needs further analysis before proceeding P4 Very low priority topic/gateway Topic gateway exp/intermediate Prior experience is likely helpful effort/hours Estimated to take one or several hours labels Sep 4, 2020
@ipfs ipfs deleted a comment from welcome bot Sep 4, 2020
@lidel lidel added the need/author-input Needs input from the original author label Sep 4, 2020
@lidel
Copy link
Member

lidel commented Sep 4, 2020

Sounds like a sensible enhancement @auburnsummer, but I have some questions before you invest time in implementing this:

  1. Do you have a specific app in mind that understands filename and not filename*?
    (Is this a real need, or just a theoretical concern?)
  2. Do we know how browsers (eg. Safari, Chromium, Firefox) behave when they see both filename and filename*?
    (Which one is picked?)
  3. My understanding is that filename will be ASCII-only:
    what type of transliteration do you have in mind?
    what happens when filename is only non-ASCII characters?

@auburnsummer
Copy link
Author

  1. At least one version of the Unity game engine's UnityWebRequest.GetResponseHeader doesn't handle filename* correctly. In my specific case, I'm working with a video game called Rhythm Doctor, which has the functionality to import custom content from the internet. It misunderstands filename* as filename.

  2. I tested with the latest version of Safari, Chromium, and Firefox, which pick filename* when both filename and filename* are present. Supposedly old versions of Safari, IE8 and older, and Android versions prior to 2016 would pick filename, but I don't have the ability to test those.

  3. Yes, filename will be ASCII only. Google Drive just replaces any non-ASCII characters with underscores, and I was intending to do the same thing here (e.g. hello café 你好.zip just becomes hello caf_ __.zip). The more complicated approach involves dragging in an ICU library which seems like too much for an edge case.

@lidel
Copy link
Member

lidel commented Sep 11, 2020

@auburnsummer sgtm, going with underscores is a way to go, makes this safe to add with low risk.
we discussed this during our weekly triage and are open to reviewing a PR if you wish to submit one 👍

@lidel lidel added status/ready Ready to be worked and removed need/analysis Needs further analysis before proceeding need/author-input Needs input from the original author labels Sep 11, 2020
@lidel
Copy link
Member

lidel commented Sep 16, 2020

Did not hear back from original author – I'll take this one.
(I am adding support for attachment mode, so can add this in the same PR)

@lidel lidel self-assigned this Sep 16, 2020
@lidel lidel added status/in-progress In progress and removed status/ready Ready to be worked labels Sep 16, 2020
lidel added a commit that referenced this issue Sep 16, 2020
This adds ASCII-only filename for clients that do not implement RFC 5987

Closes #7648
@lidel
Copy link
Member

lidel commented Sep 17, 2020

@auburnsummer I believe #7677 does what you want :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/hours Estimated to take one or several hours exp/intermediate Prior experience is likely helpful kind/enhancement A net-new feature or improvement to an existing feature P4 Very low priority status/in-progress In progress topic/gateway Topic gateway
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants