MimeKit: MessageDeliveryStatus accessors throws "Failed to parse headers." if content doesn't end with a blank line
When the last status group in a message/delivery-status MIME part does not end with a blank line the MimeParser
throws an “Failed to parse headers.” exception when calling the MessageDeliveryStatus.StatusGroups
property.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (10 by maintainers)
Commits related to this issue
- Modified MimeParser.ParseHeaders() to accept header blocks that do not end with a blank line Fixes issue #250 — committed to jstedfast/MimeKit by jstedfast 8 years ago
- Added a work-around for Office365 message/delivery-status containing encoded status groups Fixes a followup bug report in issue #250 — committed to jstedfast/MimeKit by jstedfast 2 years ago
@jstedfast sure, please do
@alex-jitbit is it ok if I end up including your test message as a unit test in MimeKit? Or should I try to scrub anything?
The issue is that the message/delivery-status content should be multiple blocks of headers (aka status groups), but after the first status group of headers, it’s base64-encoded. Turns out the base64-encoded blob is the second status group of headers.
I’ve got a work-around that checks if the first status group of headers contains a Content-Transfer-Encoding, and if so, passes the remainder of the data thru a base64 decoder to parse the rest.
I’m not 100% sure it’s caused by line breaks or even connected to the original issue. But here’s the .eml that breaks things: https://www.dropbox.com/s/bssh4zalgyo2dv5/bounced.eml?dl=0
It’s a standard bounce message sent by Outlook 365
It has a delivery status report in it, and here’s the code that breaks: