summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2017-02-28 12:43:08 +0000
committerMagnus Hagander2017-02-28 12:43:08 +0000
commit2e41b31654b80aeb3e6037fc0b31422c951040c7 (patch)
treee577505339f232e86bdd6811c5042fb71ba9e630
parentf7dbbe8995fb6fb03f0dd1c5708ba6bad13e41d3 (diff)
Properly handle UTF8 in sender names in emails
We need to treat them as structured and escape only the name, not the email part. Reported by Dagfinn Ilmari Mannsåker
-rw-r--r--pgcommitfest/commitfest/views.py5
1 files 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())