[324827] Fixed handling of invalid dates

Patch from Nikita V. Youshchenko

From: "Nikita V. Youshchenko" 
To: Debian Bug Tracking System
Subject: offlineimap: exception on mail with broken headers (+fix)
Date: Wed, 24 Aug 2005 13:41:08 +0400

Package: offlineimap
Version: 4.0.10
Severity: normal
Tags: patch

Recently I've got an exception (see below) while using offlineimap.
Exception was probably caused by invalid Date header of (likely spam)
message:
Date: Sat, 20 Aug 2005 4294967295:43:18 -0700
This commit is contained in:
John Goerzen 2005-08-24 19:01:42 +01:00
parent 8d3f3d5b42
commit 1f25b5393b

View File

@ -199,7 +199,7 @@ class IMAPFolder(BaseFolder):
raise ValueError raise ValueError
# This could raise a value error if it's not a valid format. # This could raise a value error if it's not a valid format.
date = imaplib.Time2Internaldate(datetuple) date = imaplib.Time2Internaldate(datetuple)
except ValueError: except (ValueError, OverflowError):
# Argh, sometimes it's a valid format but year is 0102 # Argh, sometimes it's a valid format but year is 0102
# or something. Argh. It seems that Time2Internaldate # or something. Argh. It seems that Time2Internaldate
# will rause a ValueError if the year is 0102 but not 1902, # will rause a ValueError if the year is 0102 but not 1902,