Save to/cc headers as-is for tracking
PATCH 1/2 Save to/cc headers as-is for tracking
If we clean the to/cc headers to get rid of all unicode escaping, we run into a Python bug that is unable to properly parse addresses, e.g.:
In [5]: from email import utils
In [6]: utils.getaddresses(['foo <[email protected]>'])
Out[6]: [('foo', '[email protected]')]
In [7]: utils.getaddresses(['Shuming [范書銘] <[email protected]>']) Out[7]:
[('', 'Shuming'),
('', ''),
('', '范書銘'),
('', ''),
('', '[email protected]')]
If we store the headers as-is from the original message, we are less likely to run into this bug, as all non-ascii sequences should be qp-escaped in the original headers:
=?big5?B?U2h1bWluZyBbrVOu0bvKXQ==?= <[email protected]>
This doesn't fix the underlying bug in Python, but works around it.
--- b4/__init__.py | 11 ++++++++--- b4/mbox.py | 4 ++-- b4/pr.py | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-)
b4/__init__.py +8 -3
@@ -2375,11 +2375,16 @@ def git_get_toplevel(path=None): return topdir -def format_addrs(pairs): +def format_addrs(pairs, clean=True): addrs = set() for pair in pairs: - # Remove any quoted-printable header junk from the name - addrs.add(email.utils.formataddr((LoreMessage.clean_header(pair[0]), LoreMessage.clean_header(pair[1])))) + pair = list(pair) + if pair[0] == pair[1]: + pair[0] = '' + if clean: + # Remove any quoted-printable header junk from the name + pair[0] = LoreMessage.clean_header(pair[0]) + addrs.add(email.utils.formataddr(pair)) # noqa return ', '.join(addrs)
b4/mbox.py +2 -2
@@ -294,8 +294,8 @@ def thanks_record_am(lser, cherrypick=None): 'subject': lmsg.full_subject, 'fromname': lmsg.fromname, 'fromemail': lmsg.fromemail, - 'to': b4.format_addrs(allto), - 'cc': b4.format_addrs(allcc), + 'to': b4.format_addrs(allto, clean=False), + 'cc': b4.format_addrs(allcc, clean=False), 'references': b4.LoreMessage.clean_header(lmsg.msg['References']), 'sentdate': b4.LoreMessage.clean_header(lmsg.msg['Date']), 'quote': b4.make_quote(lmsg.body, maxlines=5),
b4/pr.py +2 -2
@@ -225,8 +225,8 @@ def thanks_record_pr(lmsg): 'subject': lmsg.full_subject, 'fromname': lmsg.fromname, 'fromemail': lmsg.fromemail, - 'to': b4.format_addrs(allto), - 'cc': b4.format_addrs(allcc), + 'to': b4.format_addrs(allto, clean=False), + 'cc': b4.format_addrs(allcc, clean=False), 'references': b4.LoreMessage.clean_header(lmsg.msg['References']), 'remote': lmsg.pr_repo, 'ref': lmsg.pr_ref,
Signature · 1 line
2.30.2
PATCH 2/2 Loosen compatible release identifiers for install_requires
From: Kyle Meyer <[email protected]>
The install_requires entries use a compatible release operator. As an example, "requests~=2.24.0" maps to a requirement of ">= 2.24.0 and == 2.24.*". With the current version of requests (2.25.1), this leads to a ContextualVersionConflict failure at runtime.
Allowing only Z to tick in version X.Y.Z seems unnecessarily strict unless there are known problems with a particular release, and it makes it more difficult for distributions to package b4. Drop the trailing digit from all of the version identifiers, allowing both Y and Z to increase.
--- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
setup.py +3 -3
@@ -41,9 +41,9 @@ setup( data_files = [('share/man/man5', ['man/b4.5'])], keywords=['git', 'lore.kernel.org', 'patches'], install_requires=[ - 'requests~=2.24.0', - 'dkimpy~=1.0.5', - 'dnspython~=2.0.0', + 'requests~=2.24', + 'dkimpy~=1.0', + 'dnspython~=2.0', ], python_requires='>=3.6', entry_points={
Signature · 1 line
2.30.2