Support filename* parameter for Content-Disposition header of file upload

Created on 20 April 2022, over 2 years ago
Updated 19 September 2024, about 2 months ago

Problem/Motivation

I would like to upload files with UTF-8 characters in the filename using jsonapi. I expected to be able to do this by using a filename*=UTF-8'' parameter in the Content-Disposition header, but found that it's not supported yet.

Steps to reproduce

Upload a file for an entity field using jsonapi with filename* in the Content-Disposition header. Example headers:

{
          'Accept': 'application/vnd.api+json',
          'Content-Type': 'application/octet-stream',
          'Content-Disposition': 'file; filename="example.txt"; filename*="UTF-8\'\'ex%C3%A4mple.txt"'
}

The filename* parameter is ignored and the file will be named example.txt instead of exΓ€mple.txt. Removing the filename parameter throws an error because it is required.

Proposed resolution

Support and give preference to the filename* parameter as described at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Dispos...

Remaining tasks

Confirm how to handle CSpell in this case (testing filenames with utf-8 characters).
Confirm supporting filename* and utf-8 in Content-Disposition header does not count as an api change.

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

✨ Feature request
Status

RTBC

Version

11.0 πŸ”₯

Component
File moduleΒ  β†’

Last updated 2 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States cantrellnm

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡΅πŸ‡±Poland Pozi

    An interesting article explaining the problem in details:
    https://www.jmix.io/blog/utf-8-in-http-headers/

  • First commit to issue fork.
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    nicxvan β†’ changed the visibility of the branch 11.x to hidden.

  • Merge request !9146Add support for filename Extended β†’ (Open) created by nicxvan
  • Pipeline finished with Failed
    3 months ago
    Total: 133s
    #249303
  • Pipeline finished with Canceled
    3 months ago
    Total: 127s
    #249468
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    nicxvan β†’ changed the visibility of the branch 3276349-support-filename-parameter to hidden.

  • Pipeline finished with Failed
    3 months ago
    Total: 135s
    #249469
  • Pipeline finished with Failed
    3 months ago
    Total: 562s
    #249472
  • Status changed to Needs work 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I'm not sure how we should handle a word like rΓ©sumΓ© since we are specifically testing utf-8 encoding.

    For now I just /* cspell:disable-next-line */ for those entries, let me know if that needs to change.

  • Pipeline finished with Failed
    3 months ago
    Total: 518s
    #249545
  • Pipeline finished with Success
    3 months ago
    Total: 649s
    #249557
  • Status changed to Needs review 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States cantrellnm
  • Status changed to RTBC 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I've now had a chance to review the tests and change and it looks good to me.

    I hope this status is ok, I did add the cspell rules, but the merge request work I did came from the work cantrellnm did.

  • First commit to issue fork.
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    I changed several comments to conform to the coding standards line length limit of 80 characters. I also removed some cspell ignore-next-line by adding an ignore line at the top of the file. That is what we have settled on for most words non know to cspell. The exception, which is left unchanged is when ignore hashes or regexes. One of the comment I changed to improve the readability but it should not change the meaning. Therefor, leaving the RTBC.

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Added a suggested single regex to match both based on whether the * is present.

    Looks like we need a test for the lang being present too.

Production build 0.71.5 2024