From 5a54a4a239cc51eb724f9b13a3323ffcb1c7e569 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 25 2016 09:23:30 +0000 Subject: Fix the milter to get it working - Do not override the email variable/module - If there is no 'cc' address email, default it to '' so that we can check if it contains the string 'reply+' --- diff --git a/milters/comment_email_milter.py b/milters/comment_email_milter.py index e7e61af..477cdf4 100644 --- a/milters/comment_email_milter.py +++ b/milters/comment_email_milter.py @@ -132,12 +132,14 @@ class PagureMilter(Milter.Base): # 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']))) - 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] + email_address = msg['to'] + if 'reply+' in msg.get('cc', ''): + email_address = msg['cc'] + if not 'reply+' in email_address: + self.log( + 'No valid recipient email found in To/Cc: %s' + % email_address) + tohash = email_address.split('@')[0].split('+')[-1] if m.hexdigest() != tohash: self.log('hash: %s' % m.hexdigest()) self.log('tohash: %s' % tohash)