git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Karl Wiberg <kha@treskal.com>
Cc: git@vger.kernel.org
Subject: [StGit PATCH] mail: Use space rather than tab for long header folding
Date: Fri, 12 Feb 2010 15:39:05 +0000	[thread overview]
Message-ID: <20100212153905.11578.83879.stgit@pc1117.cambridge.arm.com> (raw)

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():

             reply	other threads:[~2010-02-12 15:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-12 15:39 Catalin Marinas [this message]
2010-02-12 16:09 ` [StGit PATCH] mail: Use space rather than tab for long header folding Karl Wiberg
2010-02-12 16:15   ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100212153905.11578.83879.stgit@pc1117.cambridge.arm.com \
    --to=catalin.marinas@arm.com \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=kha@treskal.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).