From 2368ff68826074056150b2d21a66ac2ad76370db Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 6 Nov 2014 23:56:47 -0800 Subject: [PATCH] ssoma-mda: Decode RFC-2047-encoded From: headers The examples in RFC 2047 have an encoded name, but an ASCII email address [1]. Make sure we handle that appropriately. [1]: http://tools.ietf.org/html/rfc2047#section-8 --- ssoma-mda | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ssoma-mda b/ssoma-mda index f02b1b1..d3b5406 100755 --- a/ssoma-mda +++ b/ssoma-mda @@ -249,11 +249,26 @@ def get_commit_message(message): def get_author(message): - """Create a pygit2.Signature for the message author.""" + """Create a pygit2.Signature for the message author. + + >>> author = get_author(message={ + ... 'From': '=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= ', + ... 'Date': 'Fri, 21 Nov 1997 09:55:06 -0600', + ... }) + >>> author.name + 'Keld Jørn Simonsen' + >>> author.email + 'keld@dkuug.dk' + >>> author.time + 880127706 + >>> author.offset + 1080 + """ author_name, author_email = _email_utils.parseaddr( message['From']) if not author_name: author_name = author_email.split('@')[0] + author_name = _decode_header(string=author_name) date = message['Date'] datetime = _email_utils.parsedate_to_datetime(date) time = int(datetime.timestamp()) @@ -265,7 +280,8 @@ def get_author(message): name=author_name, email=author_email, time=time, - offset=offset) + offset=offset, + encoding=_COMMIT_MESSAGE_ENCODING) def deliver(message=None, message_bytes=None, **kwargs): -- 2.26.2