[Reportbug-maint] Bug#849586: reportbug incorrectly short-circuits From address escaping with non-ASCII characters

Sandro Tosi morph at debian.org
Thu Jan 5 00:22:04 UTC 2017


control: forcemerge 848692 -1


On Wed, Dec 28, 2016 at 5:53 PM, Russ Allbery <rra at debian.org> wrote:
>
>     if re.match(r'[\w\s]+$', realname):
>         return '%s <%s>' % (realname, email)
>
>     addr = email.utils.formataddr((realname, email))
>
> I suspect this worked fine in Python 2, since this regex doesn't use
> the UNICODE flag.  However, in Python 3, I believe regexes are str
> types by default and therefore Unicode by default, so this will match
> non-ASCII characters, short-circuit this logic, and never call
> formataddr.
>
> I'm not sure the original motivation for the short-circuit here, but
> I suspect just removing the re.match conditional and unconditionally
> calling email.utils.formataddr will produce the correct behavior.

i just did exactly that as part of 848692 (hence the merge)


-- 
Sandro "morph" Tosi
My website: http://sandrotosi.me/
Me at Debian: http://wiki.debian.org/SandroTosi
G+: https://plus.google.com/u/0/+SandroTosi



More information about the Reportbug-maint mailing list