Message ID | 5de6864e5999c398700712fdce5d52c77d8b0a2a.1686057776.git.dev@jpoiret.xyz (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Quote author name when creating am message. | expand |
On Tue, Jun 06, 2023 at 03:23:18PM +0200, Josselin Poiret wrote: > From: Josselin Poiret <dev@jpoiret.xyz> > > Previously, if an author name needed to be quoted, `git am` would create an mbox > with invalid From: lines, such as with [1]. Escape author name in all cases. Thank you for the report. I didn't take the patch, because there is a better way to do it, but I did give you credit in the commit: https://git.kernel.org/pub/scm/utils/b4/b4.git/commit/?id=87aacf279afc3c1eda7b2e6e02e70842b4f99bc7 Best regards, Konstantin
Hi Konstantin, Konstantin Ryabitsev <konstantin@linuxfoundation.org> writes: > Thank you for the report. I didn't take the patch, because there is a better > way to do it, but I did give you credit in the commit: > > https://git.kernel.org/pub/scm/utils/b4/b4.git/commit/?id=87aacf279afc3c1eda7b2e6e02e70842b4f99bc7 It was my first time looking at b4's source so I'm thankful for the more idiomatic code! I'm hoping to contribute more to b4 in the future since we're trying to use that more and more in GNU Guix. Best,
diff --git a/b4/__init__.py b/b4/__init__.py index 9b1f69c..a1a5c92 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -2026,7 +2026,8 @@ class LoreMessage: am_msg = email.message.EmailMessage() if i.get('Author'): - hfrom = f'{i.get("Author")} <{i.get("Email")}>' + quoted_author = email.utils.quote(i.get("Author")) + hfrom = f'"{quoted_author}" <{i.get("Email")}>' else: hfrom = i.get('Email') am_msg.add_header('Subject', self.get_am_subject(indicate_reroll=False, use_subject=i.get('Subject')))