Skip to content

Bug: MimeMessageParser rejects attachments with duplicate names #219

Closed

Description

@nicolasbelisle

MimeMessageParser uses a Map for the attachments:

484 : public Map<String, DataSource> getAttachmentList()

However an email can have 2 attachments with the same name. The Map will just replace any existing attachment.

Activity

  1. bbottema commented on Aug 7, 2019

    @bbottema
    Owner

    Is this a real use case?

  2. nicolasbelisle commented on Aug 7, 2019

    @nicolasbelisle
    Author

    Yes. Real email that went through MimeMessageParser (v. 5.1.7).

  3. nicolasbelisle commented on Aug 8, 2019

    @nicolasbelisle
    Author

    Essentially replacing the Map with a List<Map.Entry) does the job
    It's already called "attachmentList" ;-)
    parsedComponents.attachmentList.put(cid, cidEntry.getValue());
    to
    parsedComponents.attachmentList.add(new AbstractMap.SimpleEntry(cid, cidEntry.getValue()));

    BTW, you can add attachments with the same name in Gmail.
    Reference nicolasbelisle@47a47f3 (There's a few other fixes in this commit however).

  4. added this to the 5.2.1 milestone on Aug 9, 2019
  5. bbottema commented on Aug 9, 2019

    @bbottema
    Owner

    Ok, you made a convincing case. If you feel up to it, I'll accept a PR on master! Or else I'll pick it up in due time.

  6. changed the title [-]MimeMessageParser and attachments[/-] [+]Bug: MimeMessageParser rejects attachments with duplicate names[/+] on Aug 16, 2019
  7. added a commit that references this issue on Aug 16, 2019
  8. modified the milestones: 5.3.0, 5.2.1 on Aug 16, 2019
  9. bbottema commented on Aug 16, 2019

    @bbottema
    Owner

    Fixed and released in 5.2.1!

  10. DasTier1 commented on Mar 12, 2021

    @DasTier1

    Seems to be still there in Simple Java Mail 6.5.0:
    package org.simplejavamail.converter.internal.mimemessage;
    MimeMessageParser :
    Line 508 : public Map<String, DataSource> getAttachmentList() {
    return this.attachmentList;
    }

    WIll not work with two attachments named e.g.:
    TSOL0038
    TSOL0038.AUF

    i.e. no suffix in one case.
    This case is used for electronic billing for healthcare in Germany.
    Works fine with different suffixes.

    #249

  11. added a commit that references this issue on Nov 14, 2021
  12. added a commit that references this issue on Dec 25, 2021
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