From 2e41b31654b80aeb3e6037fc0b31422c951040c7 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Tue, 28 Feb 2017 13:43:08 +0100 Subject: [PATCH] Properly handle UTF8 in sender names in emails MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We need to treat them as structured and escape only the name, not the email part. Reported by Dagfinn Ilmari Mannsåker --- pgcommitfest/commitfest/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index 5fda5b2..11f427e 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -11,7 +11,8 @@ from django.conf import settings from datetime import datetime from email.mime.text import MIMEText -from email.utils import formatdate, make_msgid +from email.utils import formatdate, make_msgid, formataddr +from email.header import Header from pgcommitfest.mailqueue.util import send_mail, send_simple_mail from pgcommitfest.userprofile.util import UserWrapper @@ -365,7 +366,7 @@ def comment(request, cfid, patchid, what): msg['Subject'] = 'Re: %s' % form.thread.subject msg['To'] = settings.HACKERS_EMAIL - msg['From'] = "%s %s <%s>" % (request.user.first_name, request.user.last_name, UserWrapper(request.user).email) + msg['From'] = formataddr((str(Header(u"%s %s" % (request.user.first_name, request.user.last_name), 'utf-8')), UserWrapper(request.user).email)) # CC the authors of a patch, if there are any authors = list(patch.authors.all()) -- 2.39.5