git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [StGit PATCH] mail: Use space rather than tab for long header folding
@ 2010-02-12 15:39 Catalin Marinas
  2010-02-12 16:09 ` Karl Wiberg
  0 siblings, 1 reply; 3+ messages in thread
From: Catalin Marinas @ 2010-02-12 15:39 UTC (permalink / raw)
  To: Karl Wiberg; +Cc: git

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>
---
 stgit/commands/mail.py |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py
index e1de847..34262d3 100644
--- a/stgit/commands/mail.py
+++ b/stgit/commands/mail.py
@@ -170,7 +170,7 @@ def __get_sender():
 
 def __addr_list(msg, header):
     return [addr for name, addr in
-            email.Utils.getaddresses(msg.get_all(header, []))]
+            email.Utils.getaddresses(map(str, msg.get_all(header, [])))]
 
 def __parse_addresses(msg):
     """Return a two elements tuple: (from, [to])
@@ -304,7 +304,8 @@ def __send_message(type, tmpl, options, *args):
 
 def __update_header(msg, header, addr = '', ignore = ()):
     def __addr_pairs(msg, header, extra):
-        pairs = email.Utils.getaddresses(msg.get_all(header, []) + extra)
+        pairs = email.Utils.getaddresses(map(str,
+                                             msg.get_all(header, []) + extra))
         # remove pairs without an address and resolve the aliases
         return [address_or_alias(p) for p in pairs if p[1]]
 
@@ -408,7 +409,8 @@ def __encode_message(msg):
                 pass
             words.append(email.Header.Header(uword).encode())
         new_val = ' '.join(words)
-        msg.replace_header(header, new_val)
+        msg.replace_header(header,
+                           email.Header.Header(new_val, header_name = header))
 
     # encode the body and set the MIME and encoding headers
     if msg.is_multipart():

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-02-12 16:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-12 15:39 [StGit PATCH] mail: Use space rather than tab for long header folding Catalin Marinas
2010-02-12 16:09 ` Karl Wiberg
2010-02-12 16:15   ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).