From: John Goerzen Date: Wed, 1 Aug 2007 01:25:05 +0000 (+0100) Subject: Additional date validity check X-Git-Tag: DEBIAN_offlineimap_5.99.2~4 X-Git-Url: https://code.delx.au/offlineimap/commitdiff_plain/2323fdcdb39481aeec7e3df48f5dfd1cb2e13608 Additional date validity check patch from Mike Gerber Two times today I have found my offlineimap to have died with this same situation. It appears as if certain types of messages (both spam in my situation), cause offlineimap to choke. When it does it cannot proceed. This means that when I run offlineimap, it pulls in messages from some folders, then it hits the folder with the bad message and dies, leaving undownloaded mail on the server. The only fix to this problem is to find the problem message on the server and remove it by hand. This isn't such a huge deal for me, since I run the server, but other people have to come to me to ask me to delete these messages, and until I do they cannot download their email. I have captured the output by running script during one of these incidents, this has been attached. Additionally, I have also attach the problematic message. The patch seems to work for me, might need some Python wizard and better testing, though. fixes deb#396443 --- diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 26a12fd..8772c12 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -213,6 +213,12 @@ class IMAPFolder(BaseFolder): try: if datetuple[0] < 1981: raise ValueError + + # Check for invalid date + datetuple_check = time.localtime(time.mktime(datetuple)) + if datetuple[:2] != datetuple_check[:2]: + raise ValueError + # This could raise a value error if it's not a valid format. date = imaplib.Time2Internaldate(datetuple) except (ValueError, OverflowError):