CVS: tmda/bin tmda-inject,1.87,1.88
Timothy Legant <[email protected]>
| Newsgroups | gmane.mail.spam.tmda.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tmda/tmda/bin
In directory sc8-pr-cvs1:/tmp/cvs-serv2791
Modified Files:
tmda-inject
Log Message:
Updated inject_message to use the new add_headers and purge_headers functions
in Util instead of several loops.
Index: tmda-inject
===================================================================
RCS file: /cvsroot/tmda/tmda/bin/tmda-inject,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- tmda-inject 29 Apr 2003 20:48:14 -0000 1.87
+++ tmda-inject 25 May 2003 03:22:51 -0000 1.88
@@ -268,20 +268,13 @@
del msg['X-TMDA-Fingerprint']
msg['X-TMDA-Fingerprint'] = (Cookie.make_fingerprint(hdrlist))
# Optionally, add some headers.
- if Defaults.ADDED_HEADERS_CLIENT:
- keys = Defaults.ADDED_HEADERS_CLIENT.keys()
- keys.sort()
- for k in keys:
- del msg[k]
- msg[k] = Defaults.ADDED_HEADERS_CLIENT[k]
+ Util.add_headers(msg, Defaults.ADDED_HEADERS_CLIENT)
# Optionally, remove some headers.
- if Defaults.PURGED_HEADERS:
- for hdr in Defaults.PURGED_HEADERS:
- del msg[hdr]
+ Util.purge_headers(msg, Defaults.PURGED_HEADERS_CLIENT)
# Create the custom headers.
custom_headers = [ h for h in actions.keys()
if h not in ('from', 'envelope', 'resent-from') ]
- nice_headers = []
+ nice_headers = {}
for header in custom_headers:
(cookie_type, cookie_option) = actions[header]
field = make_field(cookie_type, cookie_option, from_address, to_address)
@@ -289,11 +282,8 @@
field = message_format(field, full_name,
Defaults.MESSAGE_TAG_HEADER_STYLE)
nice_header = string.capwords(header.replace('-', ' ')).replace(' ', '-')
- nice_headers.append((nice_header, field))
- if nice_headers:
- for h, v in nice_headers:
- del msg[h]
- msg[h] = v
+ nice_headers[nice_header] = field
+ Util.add_headers(msg, nice_headers)
# Prepend a Received header.
if injections == 0:
if os.environ.has_key('TMDA_OFMIPD_RECEIVED'):
@@ -323,9 +313,7 @@
# Remove any custom headers we added for this recipient from the
# message object, else all subsequent recipients will receive them
# unconditionally.
- if nice_headers:
- for h, v in nice_headers:
- del msg[h]
+ Util.purge_headers(msg, nice_headers.keys())
######
_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs