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

Allow zero data attachments so Outlook message conversions don't crash and burn #318

Closed
LaurentFl opened this issue May 27, 2021 · 4 comments

Comments

@LaurentFl
Copy link

I get an error when converting an Outlook msg received from a sender who sends email with an attachment which has no data:
java.lang.IllegalArgumentException: data is required at org.simplejavamail.internal.util.Preconditions.verifyNonnull(Preconditions.java:41) at org.simplejavamail.internal.util.Preconditions.checkNonEmptyArgument(Preconditions.java:30) at org.simplejavamail.email.internal.EmailPopulatingBuilderImpl.withAttachment(EmailPopulatingBuilderImpl.java:1698) at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.buildEmailFromOutlookMessage(OutlookEmailConverter.java:117) at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.outlookMsgToEmailBuilder(OutlookEmailConverter.java:59) at org.simplejavamail.converter.EmailConverter.outlookMsgToEmailBuilder(EmailConverter.java:194) at org.simplejavamail.converter.EmailConverter.outlookMsgToEmailBuilder(EmailConverter.java:178)

Maybe it will be better if those attachments are ignored instead of throwing an Exception and block all the email conversion.
To fix this, we can check if attachment.getData() != null before calling builder.withAttachment() in OutlookEmailConverter.buildEmailFromOutlookMessage(OutlookEmailConverter.java:117)?
Or check if ((OutlookFileAttachment) attachment).getData() != null in OutlookMessage.fetchTrueAttachments() before adding it to fileAttachments ArrayList?

Maybe we need to keep this behavior to be RFC compliant?

@bbottema
Copy link
Owner

bbottema commented May 29, 2021

Would it be possible for you to provide a sample .msg and void main for reproducing the bug? I think the code has changed a little so the line numbers you report don't match up anymore (and I would like to inspect the code a bit deeper).

@LaurentFl
Copy link
Author

Here are 2 .msg as example.
TestNoData.zip

And simply one of those lines should reproduce the bug:
EmailConverter.outlookMsgToEML(new File("TestNoData.msg"))
or
EmailConverter.outlookMsgToEmailBuilder(new File("TestNoData.msg"))

(I'm using v6.5.4)

@bbottema
Copy link
Owner

Thanks I'll look into it asap

@bbottema bbottema changed the title Converting Outlook message containing an attachment with empty data Allow zero data attachments so Outlook message conversions don't crash and burn Dec 25, 2021
bbottema added a commit that referenced this issue Dec 25, 2021
… but we can't just ignore the source material, like an outlook message conversion)
@bbottema bbottema added this to the 6.7.2 milestone Dec 25, 2021
@bbottema
Copy link
Owner

Fix released in 6.7.2. I decided to allow for these attachments since

  • A). the metadata might still be useful and
  • B). you need that data if you want to contact the sender about missing data.

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