summaryrefslogtreecommitdiff
path: root/src/leap/mail/adaptors
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2015-03-23 12:59:12 -0400
committerKali Kaneko <kali@leap.se>2015-03-30 14:48:07 -0400
commitf97104e25fe504993615f194825a757d4c381a24 (patch)
treeff4a91777a7d385e5b986a2c1412e11939b76b4b /src/leap/mail/adaptors
parentefb6028e8d4096d113c565a3953919a5e30d0947 (diff)
[bug] re-add fix for multiple headers
This fix stores as multi-line headers that are repeated, and that were being discarded when storing them in a regular dict. It had been removed during the last refactor. I also store headers now as a case-insensitive dict, which solves other problems with the implementation of the twisted imap. Releases: 0.4.0
Diffstat (limited to 'src/leap/mail/adaptors')
-rw-r--r--src/leap/mail/adaptors/soledad.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/leap/mail/adaptors/soledad.py b/src/leap/mail/adaptors/soledad.py
index 490e014..7a1a92d 100644
--- a/src/leap/mail/adaptors/soledad.py
+++ b/src/leap/mail/adaptors/soledad.py
@@ -1114,6 +1114,7 @@ def _split_into_parts(raw):
msg, parts, chash, multi = _parse_msg(raw)
size = len(msg.as_string())
+
body_phash = walk.get_body_phash(msg)
parts_map = walk.walk_msg_tree(parts, body_phash=body_phash)
@@ -1161,16 +1162,13 @@ def _build_headers_doc(msg, chash, body_phash, parts_map):
It takes into account possibly repeated headers.
"""
- headers = msg.items()
-
- # TODO move this manipulation to IMAP
- #headers = defaultdict(list)
- #for k, v in msg.items():
- #headers[k].append(v)
- ## "fix" for repeated headers.
- #for k, v in headers.items():
- #newline = "\n%s: " % (k,)
- #headers[k] = newline.join(v)
+ headers = defaultdict(list)
+ for k, v in msg.items():
+ headers[k].append(v)
+ # "fix" for repeated headers (as in "Received:"
+ for k, v in headers.items():
+ newline = "\n%s: " % (k.lower(),)
+ headers[k] = newline.join(v)
lower_headers = lowerdict(dict(headers))
msgid = first(_MSGID_RE.findall(