Fix a behavioral change in build_email_address() on Python 3.
Review Request #11679 — Created June 25, 2021 and submitted
build_email_address()
has always been a wrapper around Python's
formataddr()
, which historically has taken a name and e-mail address
and built a resulting string in the form ofname <email>
. It handled
putting quotes around the name, if needed, and escaped certain
characters.Python 3 extended the behavior to convert full names with Unicode values
into escaped=?=utf-8?...=?=
strings. This is fine forformataddr()
,
since it's there to create suitable header values, but it's not what we
wanted in this function.This change rewrites
build_email_address()
to do its own e-mail
building. The logic is roughly the same as Python's implementation. The
meat of it is the usage of their regexes for escaping or quoting, which
we can still pull in fine.Unit tests were added to check the results when using Unicode
characters, ensuring behavior remains consistent across Python versions.
Unit tests pass on Python 2 and 3.
Summary | ID |
---|---|
d66b52b120852a186afcb2d3c1ec211cfd332cd3 |