aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@gmail.com>2010-02-12 15:36:37 +0000
committerCatalin Marinas <catalin.marinas@gmail.com>2010-03-01 15:35:26 +0000
commit1b0c0113861681974b8905dbe10a57f6831ecb87 (patch)
treebdfcd1d538ae26a1d5c5b63d9650512c18e8c9a8
parent46e9c9f20e7410c6a8570dfd3dbbb20518dc6b56 (diff)
downloadstgit-1b0c0113861681974b8905dbe10a57f6831ecb87.tar.gz
mail: Use space rather than tab for long subject header folding
The default Python implementation (at least 2.5 and earlier) fold long e-mail header lines by inserting "\n\t". This causes issues with some e-mail clients that remove both "\n\t". The RFC2822 shows that folding should be done with "\n ". The Python workaround is to use a Header object instead of a string when setting the message headers. Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
-rw-r--r--stgit/commands/mail.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py
index d0334b4..ed55fd9 100644
--- a/stgit/commands/mail.py
+++ b/stgit/commands/mail.py
@@ -426,6 +426,13 @@ def __encode_message(msg):
new_val = ' '.join(words)
msg.replace_header(header, new_val)
+ # replace the Subject string with a Header() object otherwise the long
+ # line folding is done using "\n\t" rather than "\n ", causing issues with
+ # some e-mail clients
+ subject = msg.get('subject', '')
+ msg.replace_header('subject',
+ email.Header.Header(subject, header_name = 'subject'))
+
# encode the body and set the MIME and encoding headers
if msg.is_multipart():
for p in msg.get_payload():