Skip to content

Improve encoding of attachment file names #232

Closed

Description

@fadeyev

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.

Activity

  1. bbottema commented on Oct 21, 2019

    @bbottema
    Owner

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

  2. added this to the 6.0.0 milestone on Oct 21, 2019
  3. added 2 commits that reference this issue on Oct 21, 2019
  4. bbottema commented on Oct 21, 2019

    @bbottema
    Owner

    Implemented enhancement for 6.0.0.

  5. changed the title [-]Encoding of attachment file names is done in the wrong place[/-] [+]Improve encoding of attachment file names[/+] on Dec 17, 2019
  6. bbottema commented on Dec 18, 2019

    @bbottema
    Owner

    Released in 6.0.0-rc1.

  7. bbottema commented on Jan 24, 2020

    @bbottema
    Owner

    6.0.0 has released as well, finally.

  8. bbottema commented on Jul 12, 2020

    @bbottema
    Owner

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions