You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When working with a message which has a MIME header that contains an email address with non-ASCII characters in the local part, operations that require a FormatOptions argument incorrectly process the email address if FormatOptions.International is false. Specifically, the local part is being encoded with punycode.
Platform (please complete the following information):
OS: Windows
.NET Framework: .NET 8
MimeKit Version: 4.1.0
To Reproduce
Steps to reproduce the behavior:
Build a MIME message.
For one of the email headers (e.g., From, To, CC, etc.) include an email that has non-ASCII characters in the local part. For example, उदाहरण@example.com
Write the message to a file using the default FormatOptions.
Open the message in a text viewer.
Note that the email provided in step 2 has the local part encoded using punycode. For the provided example, that would be [email protected]
Expected behavior
In this scenario, I would expect an exception to be thrown indicating that the message cannot be represented without plain ASCII headers.
Code Snippets
usingvarmessage=new MimeMessage();
message.FromFrom.Add(new MailboxAddress("Example","उद\u093eहरण@example.com"));// Finish building the MimeMessageusingvarfs=new FileStream(filePath)
message.WriteTo(FormatOptions.Default, fs);
Additional context
Based on RFC 5890, RFC 6530, and other related RFCs, only the domain part of an email address can be converted between Unicode and ASCII-only formats. These RFCs do not define a method for converting between a Unicode local part and an ASCII-only local part, leaving such decisions up to implementors. RFC 6530 section 4.3 indicates that a a user with an internationalized email address may have all-ASCII address(es) as well, either through having multiple accounts or aliases, but there is no way for an external system to know of the relationship between those accounts.
The text was updated successfully, but these errors were encountered:
st-abarker
changed the title
Punycode encoding being improperly used for email local parts when using provided FormatOptions has International = false
Punycode encoding being improperly used for email local parts
Mar 14, 2024
Describe the bug
When working with a message which has a MIME header that contains an email address with non-ASCII characters in the local part, operations that require a FormatOptions argument incorrectly process the email address if FormatOptions.International is false. Specifically, the local part is being encoded with punycode.
Platform (please complete the following information):
To Reproduce
Steps to reproduce the behavior:
उदाहरण@example.com
[email protected]
Expected behavior
In this scenario, I would expect an exception to be thrown indicating that the message cannot be represented without plain ASCII headers.
Code Snippets
Additional context
Based on RFC 5890, RFC 6530, and other related RFCs, only the domain part of an email address can be converted between Unicode and ASCII-only formats. These RFCs do not define a method for converting between a Unicode local part and an ASCII-only local part, leaving such decisions up to implementors. RFC 6530 section 4.3 indicates that a a user with an internationalized email address may have all-ASCII address(es) as well, either through having multiple accounts or aliases, but there is no way for an external system to know of the relationship between those accounts.
The text was updated successfully, but these errors were encountered: