summaryrefslogtreecommitdiff
path: root/src/mailman/handlers/cook_headers.py
diff options
context:
space:
mode:
authorAurélien Bompard2016-08-10 16:55:07 +0200
committerBarry Warsaw2016-08-23 21:53:55 -0400
commit3667b6dbc4110b12dd625e458dcdc8b3d9da7817 (patch)
treec25e7b2b179e66e243beb84a90024bcf959e1dff /src/mailman/handlers/cook_headers.py
parent711e2d20617ab85959a2446d610a860bdc306a54 (diff)
downloadmailman-3667b6dbc4110b12dd625e458dcdc8b3d9da7817.tar.gz
mailman-3667b6dbc4110b12dd625e458dcdc8b3d9da7817.tar.zst
mailman-3667b6dbc4110b12dd625e458dcdc8b3d9da7817.zip
Diffstat (limited to 'src/mailman/handlers/cook_headers.py')
-rw-r--r--src/mailman/handlers/cook_headers.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mailman/handlers/cook_headers.py b/src/mailman/handlers/cook_headers.py
index 297155d90..f43e3ad5a 100644
--- a/src/mailman/handlers/cook_headers.py
+++ b/src/mailman/handlers/cook_headers.py
@@ -18,6 +18,7 @@
"""Cook a message's headers."""
import re
+import logging
from email.header import Header
from email.utils import formataddr, getaddresses, parseaddr
@@ -28,6 +29,7 @@ from mailman.interfaces.mailinglist import Personalization, ReplyToMunging
from mailman.version import VERSION
from zope.interface import implementer
+log = logging.getLogger('mailman.error')
COMMASPACE = ', '
MAXLINELEN = 78
@@ -42,6 +44,8 @@ def uheader(mlist, s, header_name=None, continuation_ws='\t', maxlinelen=None):
there is and the charset is us-ascii then we use iso-8859-1 instead. If
the string is ascii only we use 'us-ascii' if another charset is
specified.
+
+ If the header contains a newline, truncate it (see GL#273).
"""
charset = mlist.preferred_language.charset
if NONASCII.search(s):
@@ -51,6 +55,10 @@ def uheader(mlist, s, header_name=None, continuation_ws='\t', maxlinelen=None):
else:
# there is no non-ascii so ...
charset = 'us-ascii'
+ if '\n' in s:
+ s = '{} [...]'.format(s.split('\n')[0])
+ log.warning('Header {} contains a newline, truncating it.'.format(
+ header_name, s))
return Header(s, charset, maxlinelen, header_name, continuation_ws)