#969209 reportbug: rejects Unicode in "email" setting

#969209#5
Date:
2020-08-29 10:23:03 UTC
From:
To:
Hi,

I tried setting

+---
| email "😸@43-1.org"
+---[ ~/.reportbugrc ]

but reportbug then failed:

+---
| % reportbug reportbug
| *** Welcome to reportbug.  Use ? for help at prompts. ***
| Note: bug reports are publicly archived (including the email address of the submitter).
| Detected character set: UTF-8
| Please change your locale if this is incorrect.
|
| Traceback (most recent call last):
|   File "/usr/bin/reportbug", line 2302, in <module>
|     main()
|   File "/usr/bin/reportbug", line 1107, in main
|     return iface.user_interface()
|   File "/usr/bin/reportbug", line 1328, in user_interface
|     fromaddr = utils.get_user_id(self.options.email, self.options.realname, charset)
|   File "/usr/lib/python3/dist-packages/reportbug/utils.py", line 332, in get_user_id
|     return email.utils.formataddr((realname, emailaddr))
|   File "/usr/lib/python3.8/email/utils.py", line 91, in formataddr
|     address.encode('ascii')
| UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f638' in position 0: ordinal not in range(128)
+---

Unicode in local parts should be allowed though:

+---
| The preceding changes mean that the following constructs now allow
| UTF-8:
| [...]
|   2.  Any construct that uses atoms, including but not limited to the
|       local parts of addresses and Message-IDs.  This includes
|       addresses in the "for" clauses of "Received:" header fields.
+---[ https://tools.ietf.org/html/rfc6532, Section 3.2 ]

Ansgar

#969209#10
Date:
2020-08-29 15:28:28 UTC
From:
To:
Python's bugtracker says that `email.utils.formataddr` is deprecated and
should not be used: https://bugs.python.org/issue25955#msg257039 and
gives an alternative (the email.headerregistry module with an
appropriate policy).

Ansgar