From a837569a27e20a0faaed9c6fd540f28270305d91 Mon Sep 17 00:00:00 2001
From: Kali Kaneko <kali@leap.se>
Date: Thu, 9 Jan 2014 20:03:02 -0400
Subject: Check for none in innerheaders

This was causing a bug, among other things, when saving to the Sent
folder for some messages. Closes #4914
---
 mail/src/leap/mail/walk.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'mail/src')

diff --git a/mail/src/leap/mail/walk.py b/mail/src/leap/mail/walk.py
index dc13345..1871752 100644
--- a/mail/src/leap/mail/walk.py
+++ b/mail/src/leap/mail/walk.py
@@ -111,8 +111,8 @@ def walk_msg_tree(parts, body_phash=None):
     # parts vector
     pv = list(get_parts_vector(parts))
 
-    if len(parts) == 2:
-        inner_headers = parts[1].get("headers", None)
+    inner_headers = parts[1].get("headers", None) if (
+        len(parts) == 2) else None
 
     if DEBUG:
         print "parts vector: ", pv
@@ -155,7 +155,8 @@ def walk_msg_tree(parts, body_phash=None):
         pdoc["part_map"][1]["multi"] = False
         if not pdoc["part_map"][1].get("phash", None):
             pdoc["part_map"][1]["phash"] = body_phash
-        pdoc["part_map"][1]["headers"] = inner_headers
+        if inner_headers:
+            pdoc["part_map"][1]["headers"] = inner_headers
     else:
         pdoc = outer
     pdoc["body"] = body_phash
-- 
cgit v1.2.3