------------------------------------------------------------
revno: 1633
fixes bug: https://launchpad.net/bugs/1555798
committer: Mark Sapiro <[email protected]>
branch nick: 2.1
timestamp: Thu 2016-03-10 16:41:32 -0800
message:
Fixed _set_date() in pipermail.py do do a better job.
modified:
Mailman/Archiver/pipermail.py
NEWS
--
lp:mailman/2.1
https://code.launchpad.net/~mailman-coders/mailman/2.1
Your team Mailman Checkins is subscribed to branch lp:mailman/2.1.
To unsubscribe from this branch go to
https://code.launchpad.net/~mailman-coders/mailman/2.1/+edit-subscription
=== modified file 'Mailman/Archiver/pipermail.py'
--- Mailman/Archiver/pipermail.py 2013-12-14 00:53:13 +0000
+++ Mailman/Archiver/pipermail.py 2016-03-11 00:41:32 +0000
@@ -16,6 +16,7 @@
VERSION = __version__
CACHESIZE = 100 # Number of slots in the cache
+from Mailman import mm_cfg
from Mailman import Errors
from Mailman.Mailbox import ArchiverMailbox
from Mailman.Logging.Syslog import syslog
@@ -230,22 +231,46 @@
self.body = s.readlines()
def _set_date(self, message):
- def floatdate(header):
- missing = []
- datestr = message.get(header, missing)
- if datestr is missing:
+ def floatdate(datestr):
+ if not datestr:
return None
date = parsedate_tz(datestr)
try:
return mktime_tz(date)
except (TypeError, ValueError, OverflowError):
return None
- date = floatdate('date')
+ def check_range(date):
+ """Checks for date in current Unix epoch and not further in the
+ future than mm_config.ARCHIVER_ALLOWABLE_SANE_DATE_SKEW.
+ """
+ if (date < 0 or
+ date - time.time() >
+ mm_cfg.ARCHIVER_ALLOWABLE_SANE_DATE_SKEW
+ ):
+ return False
+ return True
+ def fix_date():
+ # We have a bad date.
+ # Try a Received: header first.
+ date = floatdate(re.sub(r'^.*;\s*', '',
+ message.get('received'), flags=re.S))
+ if date and check_range(date):
+ return date
+ # Try the Unix From date from the mbox.
+ date = floatdate(re.sub(r'From \s*\S+\s+', '',
+ message.get_unixfrom()))
+ if date and check_range(date):
+ return date
+ return self._last_article_time + 1
+ date = floatdate(message.get('date'))
if date is None:
- date = floatdate('x-list-received-date')
+ date = floatdate(message.get('x-list-received-date'))
if date is None:
# What's left to try?
- date = self._last_article_time + 1
+ date = fix_date()
+ # Sanity check this date.
+ if not check_range(date):
+ date = fix_date()
self._last_article_time = date
self.date = '%011i' % date
self.datestr = message.get('date') \
=== modified file 'NEWS'
--- NEWS 2016-03-09 19:37:20 +0000
+++ NEWS 2016-03-11 00:41:32 +0000
@@ -14,6 +14,15 @@
Bug fixes and other patches
+ - Fixed the pipermail archiver to do a better job of figuring the date of
+ a post when its Date: header is missing, unparseable or has an obviously
+ out of range date. This should only affect bin/arch as ArchRunner has
+ code to fix dates at least if ARCHIVER_CLOBBER_DATE_POLICY has not been
+ set to 0 in mm_cfg.py. If posts have been added in the past to a list's
+ archive using bin/arch and an imported mbox, running bin/arch again could
+ result is some of those posts being archived with a different date.
+ (LP: #1555798)
+
- Fixed an issue with CommandRunner shunting a malformed message with a
null byte in the body. (LP: #1553888)
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org