------------------------------------------------------------
revno: 1633
fixes bug: https://launchpad.net/bugs/1555798
committer: Mark Sapiro <m...@msapiro.net>
branch nick: 2.1
timestamp: Thu 2016-03-10 17:53: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 01:53: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,21 +231,30 @@
         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)
+                date = mktime_tz(date)
+                if (date < 0 or
+                    date - time.time() >
+                        mm_cfg.ARCHIVER_ALLOWABLE_SANE_DATE_SKEW
+                   ):
+                    return None
+                return date
             except (TypeError, ValueError, OverflowError):
                 return None
-        date = floatdate('date')
-        if date is None:
-            date = floatdate('x-list-received-date')
-        if date is None:
-            # What's left to try?
+        date = floatdate(message.get('date'))
+        if date is None:
+            date = floatdate(message.get('x-list-received-date'))
+        if date is None:
+            date = floatdate(re.sub(r'^.*;\s*', '',
+                                    message.get('received'), flags=re.S))
+        if date is None:
+            date = floatdate(re.sub(r'From \s*\S+\s+', '',
+                                    message.get_unixfrom()))
+        if date is None:
             date = self._last_article_time + 1
         self._last_article_time = date
         self.date = '%011i' % date

=== modified file 'NEWS'
--- NEWS	2016-03-09 19:37:20 +0000
+++ NEWS	2016-03-11 01:53: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
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to