Skip to content
New issue

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

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

Already on GitHub? # to your account

Content-Disposition header with filename* returns not just the filename #5429

Closed
m1h43l opened this issue Sep 28, 2023 · 5 comments · Fixed by #5432
Closed

Content-Disposition header with filename* returns not just the filename #5429

m1h43l opened this issue Sep 28, 2023 · 5 comments · Fixed by #5432

Comments

@m1h43l
Copy link

m1h43l commented Sep 28, 2023

I am trying to upload a file. The receiving server (Helidon 2.x) is using jersey-media-multipart. I am getting the filename via the FormDataContentDisposition object but the filename is the whole string value from the filename* attribute from the Content-Disposition header. I would have expected just the real filename.

I have tried this with jersey-media-multipart 2.40.

I am sending this

Content-Disposition: form-data; name="avatar"; filename="Ueberflieger.jpg"; filename*=UTF-8'de'%C3%9Cberflieger.jpg

and would have expected to get just Überflieger.jpg from the ContentDisposition::getFileName method but I got UTF-8'de'%C3%9Cberflieger.jpg.

Is this the correct behaviour? If it is then how do I get the expected result of Überflieger.jpg from the filename value I get from the ContentDisposition class?

@jansupol
Copy link
Contributor

jansupol commented Oct 5, 2023

This is encoding as per RFC 5987 for Ü.

@m1h43l
Copy link
Author

m1h43l commented Oct 5, 2023

Yes, the encoded value is ok.

But what I am noting is that ContentDisposition::getFileName just returns the encoded value. It doesn't do any decoding. Is this the expected behaviour? Just returning the encoded value and the caller will have to do the decoding by himself?

@jansupol
Copy link
Contributor

jansupol commented Oct 5, 2023

Shouldn't ContentDisposition::getFileName return the filename, i.e. Ueberflieger.jpg and ContentDisposition::getExtendedFilename return Überflieger.jpg ?

@m1h43l
Copy link
Author

m1h43l commented Oct 5, 2023

There is no getExtendedFilename in jersey-media-multipart 2.40.

@NicolaIsotta
Copy link

Noticed that behavior too. I have to substring the result, it's quite annoying.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants