From patchwork Fri May 10 10:44:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Bie=C3=9Fmann?= X-Patchwork-Id: 242959 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 0FAFE2C0142 for ; Fri, 10 May 2013 20:43:40 +1000 (EST) Received: from mail-ea0-x22b.google.com (mail-ea0-x22b.google.com [IPv6:2a00:1450:4013:c01::22b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 50EDC2C00E1 for ; Fri, 10 May 2013 20:43:36 +1000 (EST) Received: by mail-ea0-f171.google.com with SMTP id b15so330651eae.2 for ; Fri, 10 May 2013 03:43:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=jQLB0X5CQedJLq23vaG0M2htH71nKcVouchtK2Gd/VM=; b=HH98lTbpGtsWZqCsc2L7o7vRhC4qHIKyXJDHUz2bsBB3iXNcwbhJlwb34WpLOFj4b5 HfUILT2nbX5u/ddx9ahfhNzNQblwi0Sk0DzjqLbtZSA6orR0jk5qVNbLYTH8AfVriFGf Lr7GMovssComf8aXCDzeY6voaG7iDPOyVn83THRXd0jbZVf5PoW57nwi1DM4ySxYkv7P KDRWnGPyD8IjWNWuyS1yBeAMlE9u0pJbyNcC1PNy8Xd+4bGL1mD3ijW3ZY4H39saZCA6 yU8hmYAyYwGs6a6ZhvbUuE9AdBu/7H8DYCSCH1JJIjrNkEDEdLnPZ+e/hZ1rsaHiNgvD 8TXg== X-Received: by 10.14.213.67 with SMTP id z43mr39864007eeo.16.1368182611695; Fri, 10 May 2013 03:43:31 -0700 (PDT) Received: from localhost ([2a01:198:47b:1:210:75ff:fe1a:cd1e]) by mx.google.com with ESMTPSA id s8sm2749812eeo.4.2013.05.10.03.43.30 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 10 May 2013 03:43:30 -0700 (PDT) From: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= To: Patchwork ML Subject: [PATCH 2/2] models: fix From header in mbox view Date: Fri, 10 May 2013 12:44:26 +0200 Message-Id: <1368182666-28892-2-git-send-email-andreas.devel@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1368182666-28892-1-git-send-email-andreas.devel@googlemail.com> References: <1368182666-28892-1-git-send-email-andreas.devel@googlemail.com> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" 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 --- This problem was mentioned in prior mails, for example http://thread.gmane.org/gmane.comp.version-control.patchwork/659 apps/patchwork/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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())