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

Bug: MimeMessageParser rejects attachments with duplicate names #219

Closed
nicolasbelisle opened this issue Aug 7, 2019 · 6 comments
Closed

Comments

@nicolasbelisle
Copy link

nicolasbelisle commented Aug 7, 2019

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.

@bbottema
Copy link
Owner

bbottema commented Aug 7, 2019

Is this a real use case?

@nicolasbelisle
Copy link
Author

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

@nicolasbelisle
Copy link
Author

nicolasbelisle commented Aug 8, 2019

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).

@bbottema bbottema added this to the 5.2.1 milestone Aug 9, 2019
@bbottema
Copy link
Owner

bbottema commented Aug 9, 2019

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.

nicolasbelisle pushed a commit to nicolasbelisle/simple-java-mail that referenced this issue Aug 9, 2019
@bbottema bbottema changed the title MimeMessageParser and attachments Bug: MimeMessageParser rejects attachments with duplicate names Aug 16, 2019
@bbottema bbottema modified the milestones: 5.3.0, 5.2.1 Aug 16, 2019
@bbottema
Copy link
Owner

Fixed and released in 5.2.1!

@DasTier1
Copy link

DasTier1 commented Mar 12, 2021

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

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

3 participants