From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "Kernel.org Tools" <tools@kernel.org>
Cc: ljs@kernel.org
Subject: [PATCH b4] Correctly quote usernames when setting From field
Date: Tue, 14 Jul 2026 14:28:04 +0100 [thread overview]
Message-ID: <20260714-b4-fix-from-v1-1-8166064bd700@kernel.org> (raw)
make_reply(), get_pr_from_github() and _build_review_email() construct the
email From field without properly quoting the user name and email.
This is especially problematic for users adopting the convention of "Joe
Bloggs (Company) <foo@bar.com>", as the text contained within parentheses
is interpreted as a comment and dropped.
Resolve the isssue by passing the name and email address through
format_addrs() as is already done for To and Cc fields.
We use clean=False as the username and email have been obtained from git
config user.[name,email] so do not need LoreMessage.clean_header() to be
applied to them.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
src/b4/__init__.py | 2 +-
src/b4/pr.py | 2 +-
src/b4/review/_review.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index d7b41ee..2682ae5 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -2530,7 +2530,7 @@ class LoreMessage:
msg = EmailMessage()
msg.set_payload(body, charset='utf-8')
msg['Subject'] = subject
- msg['From'] = f'{user_name} <{user_email}>'
+ msg['From'] = format_addrs([(user_name, user_email)], clean=False)
msg['To'] = format_addrs(deduped_to, clean=False)
if deduped_cc:
msg['Cc'] = format_addrs(deduped_cc, clean=False)
diff --git a/src/b4/pr.py b/src/b4/pr.py
index 9beaa08..7cf736d 100644
--- a/src/b4/pr.py
+++ b/src/b4/pr.py
@@ -430,7 +430,7 @@ def get_pr_from_github(ghurl: str) -> Optional[b4.LoreMessage]:
uemail = fake_email
msg = email.message.EmailMessage(policy=b4.emlpolicy)
- msg['From'] = f'{uname} <{uemail}>'
+ msg['From'] = b4.format_addrs([(uname, uemail)], clean=False)
title = prdata.get('title', '')
msg['Subject'] = f'[GIT PULL] {title}'
msg['Message-Id'] = b4.make_msgid(
diff --git a/src/b4/review/_review.py b/src/b4/review/_review.py
index 8c025ea..a3d82ac 100644
--- a/src/b4/review/_review.py
+++ b/src/b4/review/_review.py
@@ -2841,7 +2841,7 @@ def _build_review_email(
if not subject.lower().startswith('re:'):
subject = f'Re: {subject}'
msg['Subject'] = subject
- msg['From'] = f'{user_name} <{user_email}>'
+ msg['From'] = b4.format_addrs([(user_name, user_email)], clean=False)
# Build reply headers. When the user has explicitly edited the
# To/Cc fields via the ToCcScreen, honour their choices as-is.
---
base-commit: 4217c3e5d3e1eb259626142fd71b91ec6d5e3d1e
change-id: 20260714-b4-fix-from-9abdad884910
Cheers,
--
Lorenzo Stoakes (ARM) <ljs@kernel.org>
next reply other threads:[~2026-07-14 13:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 13:28 Lorenzo Stoakes (ARM) [this message]
2026-07-21 20:23 ` [PATCH b4] Correctly quote usernames when setting From field Konstantin Ryabitsev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260714-b4-fix-from-v1-1-8166064bd700@kernel.org \
--to=ljs@kernel.org \
--cc=tools@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox