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] Fix parsing addresses from headers in EML files, like a Disposition-Notification-To with umlaut #500

Closed
Faelean opened this issue Apr 4, 2024 · 1 comment

Comments

@Faelean
Copy link

Faelean commented Apr 4, 2024

When the "Disposition-Notification-To" contains an umlaut the content is encoded like this:

Disposition-Notification-To:
	=?iso-8859-1?Q?K=F6nok=2C_Danny_=5BFake_Company_=26_Co=2E_K?=
 =?iso-8859-1?Q?G=5D?= <test@fakedomain.de>

the following error occurs when trying to convert it to an Email object:

        String emlFileName = ".\\assets_sjm\\T24-01123.EML";

        try (FileInputStream fileInputStream = new FileInputStream(emlFileName)) {

            Email email = EmailConverter.emlToEmail(fileInputStream);

            printResult(email, emlFileName);

        }
Exception in thread "main" org.simplejavamail.converter.internal.mimemessage.MimeMessageParseException: Error parsing [Disposition-Notification-To] address [Könok, Danny [Fake Company & Co. KG] <test@fakedomain.de>]
	at org.simplejavamail.converter.internal.mimemessage.MimeMessageParser.createAddress(MimeMessageParser.java:316)
	at org.simplejavamail.converter.internal.mimemessage.MimeMessageParser.parseHeader(MimeMessageParser.java:162)
	at org.simplejavamail.converter.internal.mimemessage.MimeMessageParser.parseMimePartTree(MimeMessageParser.java:94)
	at org.simplejavamail.converter.internal.mimemessage.MimeMessageParser.parseMimeMessage(MimeMessageParser.java:87)
	at org.simplejavamail.converter.EmailConverter.mimeMessageToEmailBuilder(EmailConverter.java:138)
	at org.simplejavamail.converter.EmailConverter.mimeMessageToEmailBuilder(EmailConverter.java:125)
	at org.simplejavamail.converter.EmailConverter.emlToEmailBuilder(EmailConverter.java:399)
	at org.simplejavamail.converter.EmailConverter.emlToEmailBuilder(EmailConverter.java:378)
	at org.simplejavamail.converter.EmailConverter.emlToEmail(EmailConverter.java:312)
	at org.simplejavamail.converter.EmailConverter.emlToE
mail(EmailConverter.java:304)
	at de.otris.documents.simplejavamail.SimpleJavaMailTests.main(SimpleJavaMailTests.java:18)
Caused by: jakarta.mail.internet.AddressException: Illegal address in string ``Könok, Danny [Fake Company & Co. KG] <test@fakedomain.de>''
	at jakarta.mail.internet.InternetAddress.<init>(InternetAddress.java:103)
	at org.simplejavamail.converter.internal.mimemessage.MimeMessageParser.createAddress(MimeMessageParser.java:311)
	... 10 more

This does not happen with "From", the same encoded content parses as expected.

I've attached an example mail where both "Disposition-Notification-To" and "From" contain umlauts: T24-01123.zip

@bbottema bbottema changed the title Disposition-Notification-To with umlaut [bug] Fix parsing addresses from headers in EML files, like a Disposition-Notification-To with umlaut Apr 4, 2024
@bbottema bbottema added this to the 8.8.1 milestone Apr 4, 2024
bbottema added a commit that referenced this issue Apr 4, 2024
@bbottema
Copy link
Owner

bbottema commented Apr 4, 2024

Helpful as ever, I tracked down the issue easily thanks to your sample message.

I fixed it for Disposition-Notification-To, Return-Receipt-To and Return-Path (BounceTo address), as they all suffered from the same defect.

Fix released in 8.8.1. Thanks once again!

@bbottema bbottema closed this as completed Apr 4, 2024
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