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.
This commit is contained in:
Stuart Gathman
2007-09-03 16:18:45 +00:00
parent 021ea96748
commit 1fa4b72c84
+14 -7
View File
@@ -10,6 +10,9 @@
# CBV results. # CBV results.
# #
# $Log$ # $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 # Revision 1.6 2007/01/19 23:31:38 customdesigned
# Move parse_header to Milter.utils. # Move parse_header to Milter.utils.
# Test case for delayed DSN parsing. # Test case for delayed DSN parsing.
@@ -66,13 +69,17 @@ class AddrCache(object):
for ln in fp: for ln in fp:
try: try:
rcpt,ts = ln.strip().split(None,1) rcpt,ts = ln.strip().split(None,1)
l = time.strptime(ts,AddrCache.time_format) try:
t = time.mktime(l) l = time.strptime(ts,AddrCache.time_format)
if t < too_old: t = time.mktime(l)
changed = True if t < too_old:
continue changed = True
cache[rcpt.lower()] = (t,None) continue
except: cache[rcpt.lower()] = (t,None)
except: # unparsable timestamp - likely garbage
changed = True
continue
except: # manual entry (no timestamp)
cache[ln.strip().lower()] = (now,None) cache[ln.strip().lower()] = (now,None)
wfp.write(ln) wfp.write(ln)
if changed: if changed: