summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2002-07-23 06:11:12 +0000
committerbwarsaw2002-07-23 06:11:12 +0000
commit4db9d42188ae255c19db0787e074f44d04e0b480 (patch)
tree9cc1838dac09dab2cbe4b1547867977200fe0fd5
parent855ca22a19c08d6a7f9b0d78856ca8b4af16f6c6 (diff)
downloadmailman-4db9d42188ae255c19db0787e074f44d04e0b480.tar.gz
mailman-4db9d42188ae255c19db0787e074f44d04e0b480.tar.zst
mailman-4db9d42188ae255c19db0787e074f44d04e0b480.zip
prefix_subject(): This should fix Fil's duplicate encoding problem.
Before applying this patch, do this to reproduce the bug: - Set the language to something other than English (French makes a good choice) - Make sure the list has a prefix of some ascii text - Send a message to the list with the following Subject: =?iso-8859-1?Q?=E9?= Bingo, double encoding. This fixes the problem by making sure the prefix + original subject gets properly chunk encoded in a Header instance. There's a bit of extra goo in here that won't be necessary when I release email 2.2. See the comments for details. G'morning Fil! :)
-rw-r--r--Mailman/Handlers/CookHeaders.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py
index e51537062..7d3dc7d92 100644
--- a/Mailman/Handlers/CookHeaders.py
+++ b/Mailman/Handlers/CookHeaders.py
@@ -27,6 +27,7 @@ import email.Utils
from Mailman import mm_cfg
from Mailman import Utils
from Mailman.i18n import _
+from Mailman.Logging.Syslog import syslog
CONTINUATION = ',\n\t'
COMMASPACE = ', '
@@ -170,23 +171,28 @@ def prefix_subject(mlist, msg):
subject = msg['subject']
# The header may be multilingual; decode it from base64/quopri and search
# each chunk for the prefix.
+ headerbits = decode_header(subject)
has_prefix = 0
if prefix and subject:
pattern = re.escape(prefix.strip())
- for decodedsubj, charset in decode_header(subject):
+ for decodedsubj, charset in headerbits:
if re.search(pattern, decodedsubj, re.IGNORECASE):
has_prefix = 1
charset = Charset(Utils.GetCharSet(mlist.preferred_language))
# We purposefully leave no space b/w prefix and subject!
if not subject:
del msg['subject']
- msg['Subject'] = Header(prefix + _('(no subject)'),
- charset,
- header_name='Subject')
+ h = Header(prefix, charset, header_name='Subject')
+ h.append(_('(no subject)'), charset)
+ msg['Subject'] = h
elif prefix and not has_prefix:
del msg['subject']
# We'll encode the new prefix (just in case) but leave the old subject
# alone, in case it was already encoded.
- new_subject = Header(prefix, charset, 128, header_name='Subject')
- new_subject.append(subject, charset)
- msg['Subject'] = new_subject.encode()
+ h = Header(prefix, charset, 128, header_name='Subject')
+ for s, c in headerbits:
+ # BAW: This should not be necessary once email 2.2 is released.
+ if c is not None and not isinstance(c, Charset):
+ c = Charset(c)
+ h.append(s, c)
+ msg['Subject'] = h