From f6d618d52fbe1345b2780ea0e53b39305a470841 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 06 2016 09:56:16 +0000 Subject: [PATCH 1/3] Let the milter support the reply address to be in the To or the Cc field --- diff --git a/milters/comment_email_milter.py b/milters/comment_email_milter.py index 83c4026..221c5e4 100644 --- a/milters/comment_email_milter.py +++ b/milters/comment_email_milter.py @@ -125,13 +125,17 @@ class PagureMilter(Milter.Base): self.log('msg-ig %s' % msg_id) self.log('To %s' % msg['to']) + self.log('Cc %s' % msg.get('cc')) self.log('From %s' % msg['From']) # Ensure the user replied to his/her own notification, not that # they are trying to forge their ID into someone else's salt = pagure.APP.config.get('SALT_EMAIL') m = hashlib.sha512('%s%s%s' % (msg_id, salt, clean_item(msg['From']))) - tohash= msg['to'].split('@')[0].split('+')[-1] + email = msg['to'] + if 'reply+' in msg.get('cc'): + email = msg['cc'] + tohash= email.split('@')[0].split('+')[-1] if m.hexdigest() != tohash: self.log('hash: %s' % m.hexdigest()) self.log('tohash: %s' % tohash) From a2458a3161a6304885e0d1c469613ec1c1682180 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 06 2016 09:59:42 +0000 Subject: [PATCH 2/3] Code style fix --- diff --git a/milters/comment_email_milter.py b/milters/comment_email_milter.py index 221c5e4..5de9419 100644 --- a/milters/comment_email_milter.py +++ b/milters/comment_email_milter.py @@ -135,7 +135,7 @@ class PagureMilter(Milter.Base): email = msg['to'] if 'reply+' in msg.get('cc'): email = msg['cc'] - tohash= email.split('@')[0].split('+')[-1] + tohash = email.split('@')[0].split('+')[-1] if m.hexdigest() != tohash: self.log('hash: %s' % m.hexdigest()) self.log('tohash: %s' % tohash) From 9224fadac664d5fe7ded6f9b1a0ef9733df3a0ee Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 06 2016 10:01:10 +0000 Subject: [PATCH 3/3] Log if we can't find the desired recipient email in the To, Cc fields --- diff --git a/milters/comment_email_milter.py b/milters/comment_email_milter.py index 5de9419..e7e61af 100644 --- a/milters/comment_email_milter.py +++ b/milters/comment_email_milter.py @@ -135,6 +135,8 @@ class PagureMilter(Milter.Base): email = msg['to'] if 'reply+' in msg.get('cc'): email = msg['cc'] + if not 'reply+' in email: + self.log('No valid recipient email found in To/Cc: %s' % email) tohash = email.split('@')[0].split('+')[-1] if m.hexdigest() != tohash: self.log('hash: %s' % m.hexdigest())