MailKit: MimeKit.ParseException: Invalid local-part at offset 0 on Gmail Imap
This just started getting an exception being thrown from inside of Imap.ImapFolder.Fetch() with my gmail account. See below.
I understand that local-part refers to the part to the left of the @ in the email address. With the Imap diagnostic turned on, i found a French language messages a few messages before the location with the stack trace. It that has this in the local-part:
From: =?UTF-8?Q?Lib=C3=A9ration?= <newsletter@liberation.cccampaigns.net>
The gmail “show original” shows it as
From: "Libération" <newsletter@liberation.cccampaigns.net>
Disclaimer: I’m guessing that this is the messages that’s causing the crash. I cant be sure since the parse and download streams appear to be on different threads.
This is the full stack trace:
MimeKit.ParseException: Invalid local-part at offset 0
at MimeKit.InternetAddress.TryParseLocalPart(Byte[] text, Int32& index, Int32 endIndex, Boolean throwOnError, String& localpart)
at MimeKit.InternetAddress.TryParseAddrspec(Byte[] text, Int32& index, Int32 endIndex, Byte[] sentinels, Boolean throwOnError, String& addrspec, Int32& at)
at MimeKit.MailboxAddress.set_Address(String value)
at MimeKit.MailboxAddress..ctor(Encoding encoding, String name, String address)
at MailKit.Net.Imap.ImapUtils.EnvelopeAddress.ToMailboxAddress()
at MailKit.Net.Imap.ImapUtils.ParseEnvelopeAddressList(InternetAddressList list, ImapEngine engine, String format, CancellationToken cancellationToken)
at MailKit.Net.Imap.ImapUtils.ParseEnvelope(ImapEngine engine, CancellationToken cancellationToken)
at MailKit.Net.Imap.ImapFolder.FetchSummaryItems(ImapEngine engine, ImapCommand ic, Int32 index)
at MailKit.Net.Imap.ImapEngine.ProcessUntaggedResponse(CancellationToken cancellationToken)
at MailKit.Net.Imap.ImapCommand.Step()
at MailKit.Net.Imap.ImapEngine.Iterate()
at MailKit.Net.Imap.ImapEngine.Wait(ImapCommand ic)
at MailKit.Net.Imap.ImapFolder.Fetch(IList`1 uids, MessageSummaryItems items, HashSet`1 fields, CancellationToken cancellationToken)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (10 by maintainers)
Commits related to this issue
- Worked-around broken IMAP servers that include the <>'s in the ENVELOPE address tokens Fixes issue #494 — committed to jstedfast/MailKit by jstedfast 7 years ago
- Catch potential exceptions in parsing invalid addresses in an ENVELOPE This fixes the second case reported in issue #494 — committed to jstedfast/MailKit by jstedfast 7 years ago
The MailboxAddress .ctor is not meant to parse anything. Use MailboxAddress.Parse() instead.
I’m stripping whitespace before I create the mailbox address but I inserted some code to show me what it’s failing at so we will see what happens
On Fri, Jun 25, 2021, 11:04 PM Jeffrey Stedfast @.***> wrote: