summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/mailstore
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-09-01 14:00:21 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-09-01 14:00:21 +0200
commita43f3a7c9c47dc9c9239414a0eba9bbc1f3cfdbf (patch)
tree919ad8a3679e0d81f6c53d32456a199cd4b355dc /service/pixelated/adapter/mailstore
parent722edf3a306e495808c3ca751f6c74f5d6e5b138 (diff)
Encode mail addresses when replying
- Issue #448
Diffstat (limited to 'service/pixelated/adapter/mailstore')
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py
index 73ce543f..9b1afdd4 100644
--- a/service/pixelated/adapter/mailstore/leap_mailstore.py
+++ b/service/pixelated/adapter/mailstore/leap_mailstore.py
@@ -90,7 +90,7 @@ class LeapMail(Mail):
def _decoded_header_utf_8(self, header_value):
if isinstance(header_value, list):
- return [self._decoded_header_utf_8(v) for v in header_value]
+ return self.remove_duplicates([self._decoded_header_utf_8(v) for v in header_value])
else:
content, encoding = decode_header(header_value)[0]
if encoding:
@@ -114,20 +114,24 @@ class LeapMail(Mail):
def _replying_dict(self):
result = {'single': None, 'all': {'to-field': [], 'cc-field': []}}
- sender_mail = self.headers.get('Reply-To', self.headers.get('From'))
+ sender_mail = self._decoded_header_utf_8(self.headers.get('Reply-To', self.headers.get('From')))
# Issue #215: Fix for existing mails without any from address.
if sender_mail is None:
sender_mail = InputMail.FROM_EMAIL_ADDRESS
- recipients = self._reply_recipient('To')
+ recipients = self._decoded_header_utf_8(self._reply_recipient('To'))
recipients.append(sender_mail)
- ccs = self._reply_recipient('Cc')
+ recipients = self.remove_duplicates(recipients)
+ ccs = self._decoded_header_utf_8(self._reply_recipient('Cc'))
result['single'] = sender_mail
result['all']['to-field'] = recipients
result['all']['cc-field'] = ccs
return result
+ def remove_duplicates(self, recipients):
+ return list(set(recipients))
+
def _reply_recipient(self, kind):
recipients = self.headers.get(kind, [])
if not recipients: