aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman/Message.py
diff options
context:
space:
mode:
authorMark Sapiro <msapiro@value.net>2007-06-29 14:24:32 -0700
committerMark Sapiro <msapiro@value.net>2007-06-29 14:24:32 -0700
commit2f5393919571da9f8d97e68b170a386d4738e4a5 (patch)
treee3ceb711163dae8e648b4c1ebfc7a96e8f34a2c7 /Mailman/Message.py
parent3ecc719177d42627bf4f809d0e8bd523b764927d (diff)
downloadmailman2-2f5393919571da9f8d97e68b170a386d4738e4a5.tar.gz
mailman2-2f5393919571da9f8d97e68b170a386d4738e4a5.tar.xz
mailman2-2f5393919571da9f8d97e68b170a386d4738e4a5.zip
There is a bug in email 2.5.8 and possibly others, but not in 4.0.1 or
4.0.2 that causes email.Utils.getaddresses() to return a spurious (name, address) tuple if the supplied argument is multi-line. The actual bug is in email.Utils.parseaddr(), but the manifestation in Message.py is in the use of getaddresses() in get_sender() and get_senders(). This fix works around the bug by passing the header field values through Mailman.Utils.oneline().
Diffstat (limited to '')
-rw-r--r--Mailman/Message.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Mailman/Message.py b/Mailman/Message.py
index bba48421..3c2ef605 100644
--- a/Mailman/Message.py
+++ b/Mailman/Message.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2006 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2007 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -127,6 +127,10 @@ class Message(email.Message.Message):
fieldval = self[h]
if not fieldval:
continue
+ # Work around bug in email 2.5.8 (and ?) involving getaddresses()
+ # from multi-line header values. Note that cset='us-ascii' is OK
+ # since the address itself can't be RFC 2047 encoded.
+ fieldval = Utils.oneline(fieldval, 'us-ascii')
addrs = email.Utils.getaddresses([fieldval])
try:
realname, address = addrs[0]
@@ -180,6 +184,10 @@ class Message(email.Message.Message):
else:
fieldvals = self.get_all(h)
if fieldvals:
+ # See comment above in get_sender() regarding
+ # getaddresses() and multi-line headers
+ fieldvals = [Utils.oneline(fv, 'us-ascii')
+ for fv in fieldvals]
pairs.extend(email.Utils.getaddresses(fieldvals))
authors = []
for pair in pairs: