From 84ff9773326a775cf60aca6b362bc1ce2cbfb5d0 Mon Sep 17 00:00:00 2001 From: Andrew Engelbrecht Date: Tue, 11 Aug 2015 09:41:39 -0400 Subject: [PATCH] handle encrypted/signed i18l msgs w/o mime headers edward was chrashing when given encrypted or signed international input without internal mime headers. edward now defaults to utf-8 if the character set is not specified in a mime header. --- edward | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/edward b/edward index d4548ce..2ac1e61 100755 --- a/edward +++ b/edward @@ -429,20 +429,23 @@ def get_subpart_data (part): a single-part EddyMsg() object """ - charset = part.get_content_charset() - mime_decoded_bytes = part.get_payload(decode=True) - obj = EddyMsg() - obj.payload_bytes = part.as_bytes() - obj.filename = part.get_filename() - obj.content_type = part.get_content_type() - obj.description_list = part['content-description'] + mime_decoded_bytes = part.get_payload(decode=True) + charset = part.get_content_charset() # your guess is as good as a-myy-ee-ine... if charset == None: charset = 'utf-8' + payload_string = part.as_string() + if payload_string != None: + obj.payload_bytes = payload_string.encode(charset) + + obj.filename = part.get_filename() + obj.content_type = part.get_content_type() + obj.description_list = part['content-description'] + if mime_decoded_bytes != None: try: payload = PayloadPiece() -- 2.25.1