diff --git a/roundup/rfc2822.py b/roundup/rfc2822.py
index a54d34f3371ac1ac3b201b31a23f9425e3337af7..7e016c280fca036118bae1bc875e9bc08b4b3402 100644 (file)
--- a/roundup/rfc2822.py
+++ b/roundup/rfc2822.py
hqre = re.compile(r'^[A-z0-9!"#$%%&\'()*+,-./:;<=>?@\[\]^_`{|}~ ]+$')
+CRLF = '\r\n'
+
def base64_decode(s, convert_eols=None):
"""Decode a raw base64 string.
outs += unicode(section[0], charset or 'iso-8859-1', 'replace')
return outs.encode('utf-8')
-def encode_header(header):
+def encode_header(header, charset='utf-8'):
""" Will encode in quoted-printable encoding only if header
contains non latin characters
"""
if hqre.match(header):
return header
- charset = 'utf-8'
quoted = ''
#max_encoded = 76 - len(charset) - 7
for c in header:
if c == ' ':
quoted += '_'
# These characters can be included verbatim
- elif hqre.match(c):
+ elif hqre.match(c) and c not in '_=?':
quoted += c
# Otherwise, replace with hex value like =E2
else: