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

Confusing return from InternetAddressList.TryParse #762

Closed
adrianm64 opened this issue Feb 10, 2022 · 0 comments
Closed

Confusing return from InternetAddressList.TryParse #762

adrianm64 opened this issue Feb 10, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@adrianm64
Copy link

Describe the bug
Not sure if it is a bug but I find it confusing

(note the dot at the end of the name which makes it an invalid address)

InternetAddressList.TryParse("[email protected]", out var mailAddresses).

Returns true and an empty InternetAddressList. But

InternetAddressList.Parse("[email protected]");

throws exception Invalid local-part at offset 0

Platform (please complete the following information):

  • OS: Windows
  • .NET Runtime: CLR and CoreCLR
  • .NET Framework: .Net 4.8 and net6.0
  • MailKit Version: 3.1.1

Exception
Invalid local-part at offset 0

at MimeKit.InternetAddress.TryParseLocalPart(Byte[] text, Int32& index, Int32 endIndex, RfcComplianceMode compliance, Boolean skipTrailingCfws, Boolean throwOnError, String& localpart) in D:\src\MimeKit\MimeKit\InternetAddress.cs:line 309
at MimeKit.InternetAddress.TryParseAddrspec(Byte[] text, Int32& index, Int32 endIndex, Byte[] sentinels, RfcComplianceMode compliance, Boolean throwOnError, String& addrspec, Int32& at) in D:\src\MimeKit\MimeKit\InternetAddress.cs:line 377
at MimeKit.InternetAddress.TryParse(ParserOptions options, Byte[] text, Int32& index, Int32 endIndex, Int32 groupDepth, AddressParserFlags flags, InternetAddress& address) in D:\src\MimeKit\MimeKit\InternetAddress.cs:line 780
at MimeKit.InternetAddressList.TryParse(ParserOptions options, Byte[] text, Int32& index, Int32 endIndex, Boolean isGroup, Int32 groupDepth, Boolean throwOnError, List`1& addresses) in D:\src\MimeKit\MimeKit\InternetAddressList.cs:line 592
at MimeKit.InternetAddressList.Parse(ParserOptions options, String text) in D:\src\MimeKit\MimeKit\InternetAddressList.cs:line 1019
at MimeKit.InternetAddressList.Parse(String text) in D:\src\MimeKit\MimeKit\InternetAddressList.cs:line 1040

Expected behavior
I expected InternetAddressList.TryParse to either return true and a mailbox (for later validation) or return false.

@jstedfast jstedfast added the bug Something isn't working label Feb 10, 2022
@jstedfast jstedfast transferred this issue from jstedfast/MailKit Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants