summaryrefslogtreecommitdiff
path: root/alot/message.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-11-06 15:02:22 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2011-11-06 15:02:22 +0000
commitec147bb8cf2b35d48c4d73e25410f4a3c0b75bf5 (patch)
tree171c37d3f1cd357e958391c7300440a17e2e2a27 /alot/message.py
parent00aa5d6f7705ea6880516f4425775fa23ca1aa68 (diff)
added normalize parameter for decode_header
Diffstat (limited to 'alot/message.py')
-rw-r--r--alot/message.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/alot/message.py b/alot/message.py
index 5fa88720..eeeca0ae 100644
--- a/alot/message.py
+++ b/alot/message.py
@@ -243,7 +243,7 @@ def extract_body(mail, types=None):
return '\n\n'.join(body_parts)
-def decode_header(header):
+def decode_header(header, normalize=False):
"""decode a header value to a unicode string
values are usually a mixture of different substrings
@@ -252,6 +252,8 @@ def decode_header(header):
:param header: the header value
:type header: str in us-ascii
+ :param normalize: replace trailing spaces after newlines
+ :type normalize: boolean
:rtype: unicode
"""
@@ -260,7 +262,10 @@ def decode_header(header):
for v, enc in valuelist:
v = string_decode(v, enc)
decoded_list.append(string_sanitize(v))
- return u' '.join(decoded_list)
+ value = u' '.join(decoded_list)
+ if normalize:
+ value = re.sub(r'\n\s+', r' ', value)
+ return value
def encode_header(key, value):