guess_delivery_time():

* look for the timestamp of the latest 'Received' header before resorting to
   'Date' or 'Resent-Date'.  
 * let 'Resent-date' header take precedence over 'Date'. 
Document these changes in manpage and changelog. 
Closes: #1481316, #1764855, Debian bug #272666.
This commit is contained in:
Nikolaus Schulz 2007-11-13 21:13:38 +00:00
parent 4584dffe14
commit 8e5c870057
4 changed files with 24 additions and 10 deletions

View File

@ -3,6 +3,12 @@ Version 0.7.3 - UNRELEASED
* Fixed date header parsing to be precise with timezone information. Also,
when writing From_ line timestamps, don't use UTC but local time, without
timezone information.
* To determine the delivery date of a message, archivemail now looks for the
timestamp of the latest 'Received' header before resorting to 'Date' or
'Resent-Date'. This should give much better results when there is no
'Delivery-date' header. (Thanks Andrew Ferrier & Christian Brabandt)
Closes: #1481316, #1764855, Debian bug #272666.
* If present, the 'Resent-date' header now takes precedence over 'Date'.
Version 0.7.2 - 9 November 2007

View File

@ -3,7 +3,7 @@
.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/>
.\" Please send any bug reports, improvements, comments, patches,
.\" etc. to Steve Cheng <steve@ggi-project.org>.
.TH "ARCHIVEMAIL" "1" "07 November 2007" "SP" ""
.TH "ARCHIVEMAIL" "1" "13 November 2007" "SP" ""
.SH NAME
archivemail \- archive and compress your old email
@ -260,8 +260,9 @@ links or create tempfiles or archives in world-writable directories.
\fBarchivemail\fR attempts to find the delivery date of a message by
looking for valid dates in the following headers, in order of precedence:
\fBDelivery-date\fR,
\fBDate\fR and
\fBResent-Date\fR\&.
\fBReceived\fR,
\fBResent-Date\fR and
\fBDate\fR\&.
If it cannot find any valid date in these headers, it
will use the last-modified file timestamp on \fBMH\fR and
\fBMaildir\fR format mailboxes, or the date on the

View File

@ -777,14 +777,20 @@ def guess_delivery_time(message):
assert(message)
# try to guess the delivery date from various headers
# get more desparate as we go through the array
for header in ('Delivery-date', 'Date', 'Resent-Date'):
try:
date = message.getdate_tz(header)
for header in 'Delivery-date', 'Received', 'Resent-Date', 'Date':
try:
if header == 'Received':
# This should be good enough for almost all headers in the wild;
# if we're guessing wrong, parsedate_tz() will fail graciously.
token = message.getrawheader(header).rsplit(';', 1)[-1]
else:
token = message.get(header)
date = rfc822.parsedate_tz(token)
if date:
time_message = rfc822.mktime_tz(date)
vprint("using valid time found from '%s' header" % header)
return time_message
except (IndexError, ValueError, OverflowError): pass
except (AttributeError, IndexError, ValueError, OverflowError): pass
# as a second-last resort, try the date from the 'From_' line (ugly)
# this will only work from a mbox-format mailbox
if (message.unixfrom):

View File

@ -35,7 +35,7 @@
<RefEntry>
<DocInfo><Date>7 November 2007</Date></DocInfo>
<DocInfo><Date>13 November 2007</Date></DocInfo>
<RefMeta>
<RefEntryTitle>archivemail</RefEntryTitle>
@ -404,8 +404,9 @@ links or create tempfiles or archives in world-writable directories.
<Command/archivemail/ attempts to find the delivery date of a message by
looking for valid dates in the following headers, in order of precedence:
<application/Delivery-date/,
<application/Date/ and
<application/Resent-Date/.
<application/Received/,
<application/Resent-Date/ and
<application/Date/.
If it cannot find any valid date in these headers, it
will use the last-modified file timestamp on <application/MH/ and
<application/Maildir/ format mailboxes, or the date on the