From 7cb9307ff6b45fda8979c91e803e393b135f33fb Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 11 Feb 2014 03:04:04 -0400 Subject: defend against malformed fdocs during unset dirty/new --- mail/src/leap/mail/imap/messageparts.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'mail/src/leap') diff --git a/mail/src/leap/mail/imap/messageparts.py b/mail/src/leap/mail/imap/messageparts.py index 9b7de86..6f1376a 100644 --- a/mail/src/leap/mail/imap/messageparts.py +++ b/mail/src/leap/mail/imap/messageparts.py @@ -158,8 +158,11 @@ class MessageWrapper(object): """ self._new = value if self.memstore: - mbox = self.fdoc.content['mbox'] - uid = self.fdoc.content['uid'] + mbox = self.fdoc.content.get('mbox', None) + uid = self.fdoc.content.get('uid', None) + if not mbox or not uid: + logger.warning("Malformed fdoc") + return key = mbox, uid fun = [self.memstore.unset_new_queued, self.memstore.set_new_queued][int(value)] @@ -190,8 +193,11 @@ class MessageWrapper(object): """ self._dirty = value if self.memstore: - mbox = self.fdoc.content['mbox'] - uid = self.fdoc.content['uid'] + mbox = self.fdoc.content.get('mbox', None) + uid = self.fdoc.content.get('uid', None) + if not mbox or not uid: + logger.warning("Malformed fdoc") + return key = mbox, uid fun = [self.memstore.unset_dirty_queued, self.memstore.set_dirty_queued][int(value)] @@ -278,6 +284,7 @@ class MessageWrapper(object): docid_dict[self.FDOC] = self.memstore.get_docid_for_fdoc( mbox, uid) except Exception as exc: + logger.debug("Error while walking message...") logger.exception(exc) if not empty(self.fdoc.content): -- cgit v1.2.3