diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2015-08-24 20:05:38 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2015-08-24 20:05:38 -0300 |
commit | 87553d5975084ff8a8c05ec876a2ce06c134bd3a (patch) | |
tree | 9a5a1359fc908f2c3af78b5f717b03bf768638f5 /service/pixelated/adapter/mailstore | |
parent | b1657f962dd56401d4ba1de1a8a752790765fab2 (diff) |
[bug] add support for nested attachments
Diffstat (limited to 'service/pixelated/adapter/mailstore')
-rw-r--r-- | service/pixelated/adapter/mailstore/leap_mailstore.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py index a9fb5ba1..c18748b6 100644 --- a/service/pixelated/adapter/mailstore/leap_mailstore.py +++ b/service/pixelated/adapter/mailstore/leap_mailstore.py @@ -298,19 +298,23 @@ class LeapMailStore(MailStore): def _extract_attachment_info_from(self, message): wrapper = message.get_wrapper() part_maps = wrapper.hdoc.part_map + return self._extract_part_map(part_maps) + def _extract_part_map(self, part_maps): result = [] for nr, part_map in part_maps.items(): - if 'headers' in part_map: + if 'headers' in part_map and 'phash' in part_map: headers = {header[0]: header[1] for header in part_map['headers']} phash = part_map['phash'] if 'Content-Disposition' in headers: disposition = headers['Content-Disposition'] if 'attachment' in disposition: filename = _extract_filename(disposition) - encoding = headers['Content-Transfer-Encoding'] + encoding = headers.get('Content-Transfer-Encoding', None) result.append(AttachmentInfo(phash, filename, encoding)) + if 'part_map' in part_map: + result += self._extract_part_map(part_map['part_map']) return result |