]> code.delx.au - offlineimap/commitdiff
/offlineimap/head: changeset 233
authorjgoerzen <jgoerzen>
Sat, 10 Aug 2002 00:29:29 +0000 (01:29 +0100)
committerjgoerzen <jgoerzen>
Sat, 10 Aug 2002 00:29:29 +0000 (01:29 +0100)
Made more resiliant in the face of invalid dates.

offlineimap/head/debian/changelog
offlineimap/head/offlineimap/folder/IMAP.py

index 5fa753259ef8ee1df795cd0bea29a53e8e65fabd..ef211504ee8f6ee5cd36dbf10ab78f2a74383098 100644 (file)
@@ -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 <jgoerzen@complete.org>  Fri,  9 Aug 2002 17:54:01 -0500
 
index e4ab9c89d2123d127594fe605773a57a40c8d712..5c35d67b658b8be49eee9df26d61303ba13dd390 100644 (file)
@@ -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