diff options
| author | Magnus Hagander | 2017-03-11 18:33:08 +0000 |
|---|---|---|
| committer | Magnus Hagander | 2017-03-11 18:33:08 +0000 |
| commit | d745feae8d4e914f7b03d27465d6dfa495058097 (patch) | |
| tree | 86968dc466275feb922b182db6387b9a2beaa4b9 /pgcommitfest/userprofile | |
| parent | d49b2b07a8b2422173142729fe8d7624de7ef4c5 (diff) | |
Fix header encoding for To and Cc as well
Patch in 2e41b31654b80aeb3e6037fc0b31422c951040c7 only handled From and
missed the ohher tields. To make this cleaner, move the escpaping code
into the UserWrapper class.
Reported by Dagfinn Ilmari Mannsåker, but not using his patch
Diffstat (limited to 'pgcommitfest/userprofile')
| -rw-r--r-- | pgcommitfest/userprofile/util.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pgcommitfest/userprofile/util.py b/pgcommitfest/userprofile/util.py index af50caf..89b4e28 100644 --- a/pgcommitfest/userprofile/util.py +++ b/pgcommitfest/userprofile/util.py @@ -1,5 +1,7 @@ from Crypto.Hash import SHA256 from Crypto import Random +from email.utils import formataddr +from email.header import Header from models import UserProfile @@ -29,3 +31,9 @@ class UserWrapper(object): return self.user.email except UserProfile.DoesNotExist: return self.user.email + + @property + def encoded_email_header(self): + return formataddr(( + str(Header(u"%s %s" % (self.user.first_name, self.user.last_name), 'utf-8')), + self.email)) |
