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
This commit is contained in:
John Goerzen 2007-08-01 02:25:05 +01:00
parent f230590e08
commit 2323fdcdb3

View File

@ -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):