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

Underscore prefix on long attachment names #24

Closed
hm122 opened this issue Mar 22, 2016 · 4 comments
Closed

Underscore prefix on long attachment names #24

hm122 opened this issue Mar 22, 2016 · 4 comments

Comments

@hm122
Copy link

hm122 commented Mar 22, 2016

When I am using long names for mail attachments, the attachment name starts with an underscore, even though I did not set an underscore:

Content-Type: text/plain; name="_XXXXXXX_YYYYYYY_ZZZZZZZ_123456789.csv" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment;filename="_XXXXXXX_YYYYYYY_ZZZZZZZ_123456789.csv"

Do you know what might cause this problem?

@milo
Copy link
Member

milo commented Mar 22, 2016

What contains the $file when you add it by addAttachment()? The name is sanitized here.

@hm122
Copy link
Author

hm122 commented Mar 22, 2016

I have found out that this problem also depends on the mail client. The original email source looks like this:
Content-Disposition:` attachment; filename="
Filename_debug_customer_date_20160322_114204.csv"

While the file is correctly displayed in thunderbird, Outlook shows the file as "_Filename_debug_customer_date_20160322_114204.csv".

The file contains simple csv text data, the filename is set exactly as above, but without newline or spaces in front.

Following another example of with an empty file attached:

Short name (works perfectly fine):
Content-Type: application/x-empty
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="foobar.csv"

Long name (adds a new line and two white spaces or tab):
Content-Type: application/x-empty
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="
foobar_foobar_foobar_foobar_foobar_foobar_foobar_foobar_.csv"

@xsuchy09
Copy link

I can confirm this bug. For example PDF software is opening PDF file as attachment with %09 at the beginning of the filename - because of tab which is added in MimePart:append called from MimePart:encodeHeader which is called from MimePart:getEncodedHeader. When file is saving Ubuntu save it with - at the beginning. Attachment is added like:

Content-Disposition: attachment; filename="
	invoice-7lQYGxp6er2Dpb28ZdDvPOoML.pdf"

Solution is to add it like:

Content-Disposition: attachment; filename=
	"invoice-7lQYGxp6er2Dpb28ZdDvPOoML.pdf"

or don't fold header lines which is not specified in RFC. It is just good use case for terminal clients ofc.

More info in czech language:
https://forum.nette.org/cs/31371-email-prilozeny-soubor-a-podivne-09-pred-nazvem-souboru#p208896

@dg dg closed this as completed in 6f33373 Mar 11, 2020
@dg
Copy link
Member

dg commented Mar 11, 2020

@xsuchy09 Thanks for the analysis and solution.

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

4 participants