From: W. Trevor King Date: Fri, 7 Nov 2014 08:32:25 +0000 (-0800) Subject: ssoma-mda: Add compatibility decoding for the 'no' encoding X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=16110c334a61243897fb1e2df774de38bc14511d;p=ssoma-mda.git ssoma-mda: Add compatibility decoding for the 'no' encoding I'm not sure if this was a user error or a Git send-email error, but notmuch has a message with: Subject: =?no?q?=5BPATCH=203/3=5D=20Add=20=27compose=27=20command?= ... Message-Id: <1291933972-7186-4-git-send-email-felipe.contreras@gmail.com> X-Mailer: git-send-email 1.7.3.2 Without this patch, that raises: LookupError: unknown encoding: no --- diff --git a/ssoma-mda b/ssoma-mda index abbe7bc..484a51d 100755 --- a/ssoma-mda +++ b/ssoma-mda @@ -229,12 +229,20 @@ def _decode_header(string): 'Keld Jørn Simonsen' >>> _decode_header(string='Keld =?ISO-8859-1?Q?J=F8rn_Simonsen?=') 'Keld Jørn Simonsen' + + We also support a few non-standard cases for compatibility with + existing messages: + + >>> _decode_header(string='=?no?q?=5BPATCH=203/3=5D=20Add=20=27compose=27=20command?=') + "[PATCH 3/3] Add 'compose' command" """ chunks = [] for decoded, charset in _email_header.decode_header(string): if isinstance(decoded, bytes) and not charset: charset = 'ASCII' if charset: + if charset in ['no']: + charset = 'ASCII' decoded = str(decoded, charset) chunks.append(decoded) return ''.join(chunks)