Skip to content

send() with filename, which contains spaces works wrong in Firefox #14

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

Closed
kykint opened this issue May 5, 2020 · 4 comments
Closed

Comments

@kykint
Copy link

kykint commented May 5, 2020

If $filename contains spaces (e.g. "Some cool file.doc"), then in Firefox it saves with only first part of name (in the case of example 'Some').
My found quick fix:
WAS:

'Content-Disposition: ' . $disposition .
                '; filename=' . $filename .
                "; filename*=UTF-8''" . rawurlencode($filename)

BECOME

'Content-Disposition: ' . $disposition .
                '; filename=' . rawurlencode($filename) .
                "; filename*=UTF-8''" . rawurlencode($filename)
@kykint
Copy link
Author

kykint commented May 5, 2020

Another and better way is to add double quotes according to RFC: https://www.ietf.org/rfc/rfc2231.txt

'Content-Disposition: ' . $disposition .
                '; filename="' . rawurlencode($filename) . '"' .
                "; filename*=UTF-8''" . rawurlencode($filename)

@mikehaertl
Copy link
Owner

Looks reasonable to me. I just wonder if we really also need the extra rawurlencode() or if adding double qoutes wouldn't suffice. The example in RFC 6266 also only uses double quotes:

Content-Disposition: attachment;
                          filename="EURO rates";
                          filename*=utf-8''%e2%82%ac%20rates

We simply forgot to add them in #7. Does it also work for you if you only add double quotes?

Sidenote: Actually I'm also a little surprised that Firefox still uses the first line without encoding details. I would have expected that any modern browser can understand the second variant.

@kykint
Copy link
Author

kykint commented May 6, 2020

Yes, double quotes work fine in Firefox

mikehaertl added a commit that referenced this issue May 6, 2020
@mikehaertl
Copy link
Owner

Great. I just released 1.1.4 containing this fix. Thanks for bringing this up.

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

No branches or pull requests

2 participants