Code Monkey home page Code Monkey logo

Comments (4)

hm122 avatar hm122 commented on June 1, 2024 1

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"

from mail.

dg avatar dg commented on June 1, 2024 1

@xsuchy09 Thanks for the analysis and solution.

from mail.

milo avatar milo commented on June 1, 2024

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

from mail.

xsuchy09 avatar xsuchy09 commented on June 1, 2024

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

from mail.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.