-
Notifications
You must be signed in to change notification settings - Fork 43
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
Fix Content-Disposition header in case of filenames with unicode characters or spaces #68
base: master
Are you sure you want to change the base?
Conversation
Instead of Content-Disposition: "attachment; file=a b.pdf" this outputs Content-Disposition: attachment; file="a b.pdf" The quotation marks are introduced always; therefore this breaks compatibility if filenames are quoted manually. Then again, the quotation marks around "attachment; file=..." where introduced before this change already if e.g. the filename contained umlaute and didn't respect quoted filenames.
This change introduces a breaking API change, which I'd rather avoid. It also doesn't seem strictly necessary: from what I can tell, doing the encoding when generating the headers with a |
By breaking API change you mean users calling the method with quoted filenames I assume? I get that that might break stuff (although the parameter is named About what the various relevant RFCs state, I have to admit I don't know, what is valid and correct in theory. Possibly, only providing ASCII filenames in quotes ( However, for the practical part: I have tested various cases and have not been able to successfully send a unicode filename to GMail. GMail does not seem to support escaping the whole header (in one case the filename was quoted before encoding, in the other case not - both don't work)
but has no issues with:
which means with the current version of mime-mail there is no possibility of sending attachments with unicode filenames to a gmail client (unless I'm missing something else...) Another way could be provide a way to use |
I did some more tests without adding explicit quotes. With that there should not be any behaviour change for ASCII filenames. Using the following filename parameters:
I sent mails to three different accounts with and without my PR:
|
No, I mean the fact that the public API for this package includes the I still think it should be possible to do the escaping without changing that API, specifically by changing how the original |
Okay, I get it - changing the What I can tell (or guess), skipping over (some of the) relevant RFCs and more pragmatically testing it:
Considering these points you are right to oppose the change. Although it would be nice to have a way of pragmatically allowing for unicode filenames. Maybe just adding |
I don't mind including the
|
It's possible to do it by changing a detail in Do you have in mind another way of enabling this encode? |
No I don’t have anything else in mind |
Fixes #54
The implementation is not the most elegant but should be quite easy to understand. Feel free to suggest improvements.
Edit: After recent changes no longer related to #54 but exclusively about Unicode filenames.