From 9d1a4e2275e1632cb086838f7e3ed5266a93be3c Mon Sep 17 00:00:00 2001 From: jgoerzen Date: Sat, 10 Aug 2002 01:29:29 +0100 Subject: [PATCH] /offlineimap/head: changeset 233 Made more resiliant in the face of invalid dates. --- offlineimap/head/debian/changelog | 1 + offlineimap/head/offlineimap/folder/IMAP.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/offlineimap/head/debian/changelog b/offlineimap/head/debian/changelog index 5fa7532..ef21150 100644 --- a/offlineimap/head/debian/changelog +++ b/offlineimap/head/debian/changelog @@ -6,6 +6,7 @@ offlineimap (3.2.5) unstable; urgency=low options: pythonfile and foldersort. Fixes [complete.org #29], and for Debian, Closes: #155637. * Added documentation for the above features. + * Even more resiliant in the face of invalid Date headers. Closes: #155994. -- John Goerzen Fri, 9 Aug 2002 17:54:01 -0500 diff --git a/offlineimap/head/offlineimap/folder/IMAP.py b/offlineimap/head/offlineimap/folder/IMAP.py index e4ab9c8..5c35d67 100644 --- a/offlineimap/head/offlineimap/folder/IMAP.py +++ b/offlineimap/head/offlineimap/folder/IMAP.py @@ -118,10 +118,15 @@ class IMAPFolder(BaseFolder): if datetuple == None: datetuple = time.localtime() try: - date = imaplib.Time2Internaldate(datetuple) + if datetuple[0] < 1981: + raise ValueError + # This could raise a value error if it's not a valid format. + date = imaplib.Time2Internaldate(datetuple) except ValueError: # Argh, sometimes it's a valid format but year is 0102 - # or something. Argh. + # or something. Argh. It seems that Time2Internaldate + # will rause a ValueError if the year is 0102 but not 1902, + # but some IMAP servers nonetheless choke on 1902. date = imaplib.Time2Internaldate(time.localtime()) if content.find("\r\n") == -1: # Convert line endings if not already