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

Improve encoding of attachment file names #232

Closed
fadeyev opened this issue Oct 20, 2019 · 5 comments
Closed

Improve encoding of attachment file names #232

fadeyev opened this issue Oct 20, 2019 · 5 comments

Comments

@fadeyev
Copy link

fadeyev commented Oct 20, 2019

The org.simplejavamail.email.internal.EmailPopulatingBuilderImpl#withAttachment() methods contain call to MiscUtil.encodeText(text) which encode attachment names. If I want later to query attachments on my Email object, I'll see encoded messages, which are different from what was populated. It's not very convenient, I would expect this encoding to happen at a later stage, just before sending the email, keeping Java model clean and not overriding values I populated it with initially.

When parsing an msg file it also creates a problem, since resulting Email object won't have original file name at all - I have to decode it manually.

Morever, MimeUtility.encodeText() and MimeUtility.decodeText() do not work reliably on all platforms. I couldn't get to the bottom of it, but on my machine MimeUtility.encodeText(text) produces output which can't be parsed by MimeUtility.decodeText(text), although MimeUtility.encodeText(text, "UTF-8", "B") works well in all cases.

@bbottema
Copy link
Owner

Good points all around. I take it you're not on a released version, since you're quoting 6.0.0 develop code?

@bbottema bbottema added this to the 6.0.0 milestone Oct 21, 2019
bbottema added a commit that referenced this issue Oct 21, 2019
…hase, keeping the Email model clean. Also improved mime text encoding to use cross-platform base64 encoding
bbottema added a commit that referenced this issue Oct 21, 2019
…hase, keeping the Email model clean. Also improved mime text encoding to use cross-platform base64 encoding
@bbottema
Copy link
Owner

Implemented enhancement for 6.0.0.

@bbottema bbottema changed the title Encoding of attachment file names is done in the wrong place Improve encoding of attachment file names Dec 17, 2019
@bbottema
Copy link
Owner

Released in 6.0.0-rc1.

@bbottema
Copy link
Owner

6.0.0 has released as well, finally.

@bbottema
Copy link
Owner

bbottema commented Jul 12, 2020

FYI, as per #271 and https://javaee.github.io/javamail/FAQ#encodefilename, I'm going to turn off encoding of filenames, but I will make sure the value it is tested for injection attacks.

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

No branches or pull requests

2 participants