diff options
author | Ruben Pollan <meskio@sindominio.net> | 2015-03-30 22:46:18 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2015-03-30 22:46:18 +0200 |
commit | d64fb189cc7c05272e0558085740efd8df2598dd (patch) | |
tree | 7bb82a2ff750c5dd830201a2aa730e29eabf7168 /src/leap/mail/imap/messages.py | |
parent | 1568761f4fa7a7f8a9b0caec79ed2552b6c73ba7 (diff) | |
parent | 8e916eeadfcd76d50b54a2621d789e6a296dcce6 (diff) |
Merge branch 'kali/bug/several-mime-fixes' into develop
Diffstat (limited to 'src/leap/mail/imap/messages.py')
-rw-r--r-- | src/leap/mail/imap/messages.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/leap/mail/imap/messages.py b/src/leap/mail/imap/messages.py index 02aac2e..4c6f10d 100644 --- a/src/leap/mail/imap/messages.py +++ b/src/leap/mail/imap/messages.py @@ -22,7 +22,7 @@ from twisted.mail import imap4 from twisted.internet import defer from zope.interface import implements -from leap.mail.utils import find_charset +from leap.mail.utils import find_charset, CaseInsensitiveDict logger = logging.getLogger(__name__) @@ -228,13 +228,13 @@ def _format_headers(headers, negate, *names): # default to most likely standard charset = find_charset(headers, "utf-8") - _headers = dict() - for key, value in headers.items(): - # twisted imap server expects *some* headers to be lowercase - # We could use a CaseInsensitiveDict here... - if key.lower() == "content-type": - key = key.lower() + # We will return a copy of the headers dictionary that + # will allow case-insensitive lookups. In some parts of the twisted imap + # server code the keys are expected to be in lower case, and in this way + # we avoid having to convert them. + _headers = CaseInsensitiveDict() + for key, value in headers.items(): if not isinstance(key, str): key = key.encode(charset, 'replace') if not isinstance(value, str): @@ -247,4 +247,5 @@ def _format_headers(headers, negate, *names): # filter original dict by negate-condition if cond(key): _headers[key] = value + return _headers |