Fixed a bug where archivemail would abort if it got a date header

with a completely blank value.
This commit is contained in:
Paul Rodger 2002-05-07 12:14:29 +00:00
parent e4adb7b222
commit 7c8b58dea3
6 changed files with 27 additions and 8 deletions

View File

@ -1,4 +1,8 @@
Version 0.4.7 - ???
* Fixed a bug where archivemail would abort if it received a date header
with a completely blank value.
Version 0.4.6 - 6 May 2002 Version 0.4.6 - 6 May 2002
* Fixed a bug where the os.rename() calls could fail if we were moving * Fixed a bug where the os.rename() calls could fail if we were moving
temporary files across different filesystems/partitions. temporary files across different filesystems/partitions.

View File

@ -1,5 +1,5 @@
VERSION=0.4.6 VERSION=0.4.7
VERSION_TAG=v$(subst .,_,$(VERSION)) VERSION_TAG=v$(subst .,_,$(VERSION))
TARFILE=archivemail-$(VERSION).tar.gz TARFILE=archivemail-$(VERSION).tar.gz
@ -21,6 +21,12 @@ sdist: clobber doc
cp archivemail.py archivemail cp archivemail.py archivemail
fakeroot python setup.py sdist fakeroot python setup.py sdist
rm archivemail rm archivemail
bdist_rpm: clobber doc
cp archivemail.py archivemail
fakeroot python setup.py bdist_rpm
rm archivemail
tag: tag:
cvs tag -F current cvs tag -F current
cvs tag -F $(VERSION_TAG) cvs tag -F $(VERSION_TAG)

2
TODO
View File

@ -1,5 +1,5 @@
Goals for next minor release (0.4.7): Goals for next minor release (0.4.8):
------------------------------------- -------------------------------------
* Think about the best way to specify the names of archives created with * Think about the best way to specify the names of archives created with
possibly an --archive-name option. possibly an --archive-name option.

View File

@ -22,7 +22,7 @@ Website: http://archivemail.sourceforge.net/
""" """
# global administrivia # global administrivia
__version__ = "archivemail v0.4.6" __version__ = "archivemail v0.4.7"
__cvs_id__ = "$Id$" __cvs_id__ = "$Id$"
__copyright__ = """Copyright (C) 2002 Paul Rodger <paul@paulrodger.com> __copyright__ = """Copyright (C) 2002 Paul Rodger <paul@paulrodger.com>
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
@ -670,14 +670,14 @@ def guess_delivery_time(message):
# try to guess the delivery date from various headers # try to guess the delivery date from various headers
# get more desparate as we go through the array # get more desparate as we go through the array
for header in ('Delivery-date', 'Date', 'Resent-Date'): for header in ('Delivery-date', 'Date', 'Resent-Date'):
try:
date = message.getdate(header) date = message.getdate(header)
if date: if date:
try:
time_message = time.mktime(date) time_message = time.mktime(date)
assert(time_message) assert(time_message)
vprint("using valid time found from '%s' header" % header) vprint("using valid time found from '%s' header" % header)
return time_message return time_message
except (ValueError, OverflowError): pass except (IndexError, ValueError, OverflowError): pass
# as a second-last resort, try the date from the 'From_' line (ugly) # as a second-last resort, try the date from the 'From_' line (ugly)
# this will only work from a mbox-format mailbox # this will only work from a mbox-format mailbox
if (message.unixfrom): if (message.unixfrom):

View File

@ -19,7 +19,7 @@ check_python_version() # define & run this early - 'distutils.core' is new
from distutils.core import setup from distutils.core import setup
setup(name="archivemail", setup(name="archivemail",
version="0.4.6", version="0.4.7",
description="archive and compress old email", description="archive and compress old email",
license="GNU GPL", license="GNU GPL",
url="http://archivemail.sourceforge.net/", url="http://archivemail.sourceforge.net/",

View File

@ -563,6 +563,15 @@ This is after the ^From line"""
'Date' : None, 'Date' : None,
'Resent-Date' : 'Fri, 28 Jul 2000 16:11:36 +1000', 'Resent-Date' : 'Fri, 28 Jul 2000 16:11:36 +1000',
}, },
{ # completely blank dates were crashing < version 0.4.7
'From_' : 'sender@dummy.domain Fri Jul 28 16:11:36 2000',
'Date' : '',
},
{ # completely blank dates were crashing < version 0.4.7
'From_' : 'sender@dummy.domain Fri Jul 28 16:11:36 2000',
'Date' : '',
'Resent-Date' : '',
},
) )
for headers in weird_headers: for headers in weird_headers:
self.setUp() self.setUp()