[Nym3-commit] r291 - trunk/nym3
jr at conuropsis.org
jr at conuropsis.org
Fri Jun 10 19:55:24 CEST 2005
Author: jr
Date: 2005-06-10 19:55:22 +0200 (Fri, 10 Jun 2005)
New Revision: 291
Modified:
trunk/nym3/Mail.py
Log:
add header filtering for the relayed messages
Modified: trunk/nym3/Mail.py
===================================================================
--- trunk/nym3/Mail.py 2005-06-10 14:11:01 UTC (rev 290)
+++ trunk/nym3/Mail.py 2005-06-10 17:55:22 UTC (rev 291)
@@ -44,6 +44,11 @@
oldestMid = chr(0) * midLen
"""Special value of a mid, older than any othany other mid"""
+forbidden_headers = ['from', 'received', 'sender', 'reply-to', 'return-path',
+ 'user-agent']
+"""The list of headers that are removed from a message before it is relayed"""
+#TODO complete this list, how do we process msgid? remove and add another one?
+
class SeqNotFound(Exception): pass
def synopsize(msg, seq):
@@ -150,11 +155,18 @@
(q, r) = divmod(i, 16)
return hex(q)[2:] + hex(r)[2:]
+def filter_header(body):
+ par = email.Parser.HeaderParser()
+ message = par.parsestr(msg)
+ for h in forbidden_headers:
+ if message.has_key(h):
+ del message[h]
+ return message.as_string()
+
def relay(nym, rt, ri, sname, body):
"""relay the e-mail in body according to the routing type rt
and the routing info ri for the nymholder of nym"""
- # TODO : we must be *way* more careful with filtering headers and such
- # I think
+ body = filter_header(body)
b = 'From: ' + nym + '@' + sname + "\n\n" + body
fname = tmpFileMsg(b) #TODO we can avoid the tempfile with some fd manipultation : exec mixminion, write b in its stdin
mixcmd = "mixminion send -t 0x" + b2s(rt[0]) + b2s(rt[1]) + ":" + ri + " -i " + fname
More information about the Nym3-commit
mailing list