From d581a110f4d76542717500d68d4f19aa8c46b299 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 23 Feb 2018 11:19:50 -0500 Subject: [PATCH] IDN encode/decode the local part of mailbox addresses as well Fixes https://github.com/jstedfast/MailKit/issues/649 --- MimeKit/MailboxAddress.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MimeKit/MailboxAddress.cs b/MimeKit/MailboxAddress.cs index b75a42ece1..bc8dc62b38 100644 --- a/MimeKit/MailboxAddress.cs +++ b/MimeKit/MailboxAddress.cs @@ -312,6 +312,9 @@ static string EncodeAddrspec (string addrspec, int at) var domain = addrspec.Substring (at + 1); var local = addrspec.Substring (0, at); + if (ParseUtils.IsInternational (local)) + local = ParseUtils.IdnEncode (local); + if (ParseUtils.IsInternational (domain)) domain = ParseUtils.IdnEncode (domain); @@ -361,6 +364,9 @@ static string DecodeAddrspec (string addrspec, int at) var domain = addrspec.Substring (at + 1); var local = addrspec.Substring (0, at); + if (ParseUtils.IsIdnEncoded (local)) + local = ParseUtils.IdnDecode (local); + if (ParseUtils.IsIdnEncoded (domain)) domain = ParseUtils.IdnDecode (domain);