summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorAndreas Bießmann <andreas.devel@googlemail.com>2013-05-10 00:44:26 +0000
committerJeremy Kerr <jk@ozlabs.org>2013-05-14 18:36:04 +0800
commit2f0eb64a6d543b26aa0a38ff1d5a09389a5b2f5c (patch)
treee7c5956c11a987c862a4a58ab1a1193a8b0cbd9e /apps
parentb75cf75bf2b9aa0012f97e48936843f9bc6f1a9d (diff)
downloadpatchwork-2f0eb64a6d543b26aa0a38ff1d5a09389a5b2f5c.tar.bz2
patchwork-2f0eb64a6d543b26aa0a38ff1d5a09389a5b2f5c.tar.xz
models: fix From header in mbox view
The From header in mbox view was corrupt for patch submitters with non-ASCII characters in their names. RFC 2822 requires to retain the mail as ASCII in braces '<' and '>' while the name should be coded. Before we coded the whole string which led to some MUA misinterpret the From header (while git could manage it). Fix this by coding just the name and let the email untouched. Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'apps')
-rw-r--r--apps/patchwork/models.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/apps/patchwork/models.py b/apps/patchwork/models.py
index 9129aab..a9e70ce 100644
--- a/apps/patchwork/models.py
+++ b/apps/patchwork/models.py
@@ -32,12 +32,14 @@ try:
from email.mime.nonmultipart import MIMENonMultipart
from email.encoders import encode_7or8bit
from email.parser import HeaderParser
+ from email.header import Header
import email.utils
except ImportError:
# Python 2.4 compatibility
from email.MIMENonMultipart import MIMENonMultipart
from email.Encoders import encode_7or8bit
from email.Parser import HeaderParser
+ from email.Header import Header
import email.Utils
email.utils = email.Utils
@@ -281,7 +283,9 @@ class Patch(models.Model):
mail['Subject'] = self.name
mail['Date'] = email.utils.formatdate(
time.mktime(self.date.utctimetuple()))
- mail['From'] = unicode(self.submitter)
+ mail['From'] = email.utils.formataddr((
+ str(Header(self.submitter.name, mail.patch_charset)),
+ self.submitter.email))
mail['X-Patchwork-Id'] = str(self.id)
mail['Message-Id'] = self.msgid
mail.set_unixfrom('From patchwork ' + self.date.ctime())