From 1fa4b72c84b7a40787a83241b234355ada380a24 Mon Sep 17 00:00:00 2001 From: Stuart Gathman <stuart@gathman.org> Date: Mon, 3 Sep 2007 16:18:45 +0000 Subject: [PATCH] Delete unparseable timestamps when loading address cache. These have arisen because of failure to parse MAIL FROM properly. Will have to tighten up MAIL FROM parsing to match RFC. --- Milter/cache.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Milter/cache.py b/Milter/cache.py index e8ab0b5..16a5a1b 100644 --- a/Milter/cache.py +++ b/Milter/cache.py @@ -10,6 +10,9 @@ # CBV results. # # $Log$ +# Revision 1.7 2007/01/25 22:47:26 customdesigned +# Persist blacklisting from delayed DSNs. +# # Revision 1.6 2007/01/19 23:31:38 customdesigned # Move parse_header to Milter.utils. # Test case for delayed DSN parsing. @@ -66,13 +69,17 @@ class AddrCache(object): for ln in fp: try: rcpt,ts = ln.strip().split(None,1) - l = time.strptime(ts,AddrCache.time_format) - t = time.mktime(l) - if t < too_old: - changed = True - continue - cache[rcpt.lower()] = (t,None) - except: + try: + l = time.strptime(ts,AddrCache.time_format) + t = time.mktime(l) + if t < too_old: + changed = True + continue + cache[rcpt.lower()] = (t,None) + except: # unparsable timestamp - likely garbage + changed = True + continue + except: # manual entry (no timestamp) cache[ln.strip().lower()] = (now,None) wfp.write(ln) if changed: -- GitLab