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: IllegalArgumentException on parsing empty header name and value (when parsing Outlook message) #449

Closed
piu130 opened this issue Mar 3, 2023 · 3 comments

Comments

@piu130
Copy link

piu130 commented Mar 3, 2023

When parsing msgs, sometimes there is an empty header at the beginning. parseHeader then crashes, because of the empty name.
I cannot provide the email, since it's from production. Here is a screenshot of the first few headers:
image
As you can see, the name and value is blank.

As a fix, I would suggest to ignore headers with blank name+value.

What do you think?

Relevant code.

Stacktrace when calling org.simplejavamail.converter.EmailConverter.outlookMsgToEmail:

Suppressed: java.lang.IllegalArgumentException: name is required
	at org.simplejavamail.internal.util.Preconditions.verifyNonnullOrEmpty(Preconditions.java:49)
	at org.simplejavamail.internal.util.Preconditions.checkNonEmptyArgument(Preconditions.java:30)
	at org.simplejavamail.email.internal.EmailPopulatingBuilderImpl.withHeader(EmailPopulatingBuilderImpl.java:1705)
	at org.simplejavamail.email.internal.EmailPopulatingBuilderImpl.withHeader(EmailPopulatingBuilderImpl.java:1697)
	at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.parseHeader(OutlookEmailConverter.java:156)
	at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.lambda$null$0(OutlookEmailConverter.java:104)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.lambda$buildEmailFromOutlookMessage$1(OutlookEmailConverter.java:104)
	at java.base/java.util.HashMap.forEach(HashMap.java:1421)
	at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.buildEmailFromOutlookMessage(OutlookEmailConverter.java:104)
	at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.outlookMsgToEmailBuilder(OutlookEmailConverter.java:89)
	at org.simplejavamail.converter.EmailConverter.outlookMsgToEmailBuilder(EmailConverter.java:245)
	at org.simplejavamail.converter.EmailConverter.outlookMsgToEmail(EmailConverter.java:227)
	at org.simplejavamail.converter.EmailConverter.outlookMsgToEmail(EmailConverter.java:219)
@bbottema
Copy link
Owner

bbottema commented Mar 5, 2023

Agreed, when parsing the MimeMessage, empty/invalid headers should just be ignored.

@bbottema bbottema added this to the 8.0.0 milestone Mar 8, 2023
@bbottema bbottema changed the title [bugfix] crash on parsing empty header name and value Bug: IllegalArgumentException on parsing empty header name and value (when parsing Outlook message) Mar 8, 2023
@bbottema
Copy link
Owner

bbottema commented Mar 8, 2023

Fix released in 8.0.0. Please let me know if this works for you!

@bbottema bbottema closed this as completed Mar 8, 2023
@piu130
Copy link
Author

piu130 commented Mar 13, 2023

Thank you very much for the fast fix @bbottema . It works now :)

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