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

CUST-932 Add message/rfc822-headers as an rfc header #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tiger-zz
Copy link

@tiger-zz tiger-zz commented Aug 16, 2022

Background

We were failing to parse a bounce message that had this sub-part MIME:

// some headers ommitted for brevity
Return-Path: <>
Date: Tue, 07 Jun 2022 13:04:20 +0200
From: "Mail Delivery System" <[email protected]>
To: [email protected]
Subject: Mail delivery failed: returning message to sender
Auto-Submitted: auto-replied
Content-Type: multipart/report;boundary="4zbut9xw88wjbg96ad6j2jsqofz0dm82mspkaumnz24trpanhmdj56iegc03veyln1s";
 report-type="delivery-status"
MIME-Version: 1.0
X-UI-Out-Filterresults: unknown:0;V03:K0:lz0CEy2Glmc=:T1Qr3hOrYeek9s2b714PbA
 ==
X-Spam-Flag: NO

--4zbut9xw88wjbg96ad6j2jsqofz0dm82mspkaumnz24trpanhmdj56iegc03veyln1s
// a few other mimeparts

--4zbut9xw88wjbg96ad6j2jsqofz0dm82mspkaumnz24trpanhmdj56iegc03veyln1s
Content-Type: message/rfc822-headers
Content-Transfer-Encoding: 7bit

//Some headers ommitted
Date: Tue, 7 Jun 2022 11:04:19 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Flag: YES
X-Spam-Flag: YES

--4zbut9xw88wjbg96ad6j2jsqofz0dm82mspkaumnz24trpanhmdj56iegc03veyln1s--

Only the overall MIME multipart MIME part and the erronous MIME part were included. The existing flanker library did not treat the Content-Type header in the message/rfc822-headers section correctly as it did not properly categorize the Content-Type of message/rfc822-headers as a container

Tests

Made the change to my local instance of flanker, than ran our parsing logic against the failing mime. This parsed the mime correctly

I could not get the nosetests to run correctly on my local machine

@tiger-zz tiger-zz requested a review from a team August 16, 2022 23:07
@@ -72,7 +72,7 @@ def is_headers_container(self):
self.is_disposition_notification()

def is_rfc_headers(self):
return self == 'text/rfc822-headers'
return self == 'text/rfc822-headers' or 'message/rfc822-headers'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this not be self == 'text/rfc822-headers' or self == 'message/rfc822-headers'? this method is supposed to return a bool but instead, you are trying to return the 'message/rfc822-headers' string when self == 'text/rfc822-headers' condition is not met 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants