Skip to contentSkip to conversation

Avoid quoting email names in trailers

PATCH In review Rob Herring (Arm) 2 participants 3 messages Apr 8, 2025 – Jun 20, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Avoid quoting email names in trailers

A somewhat common pattern is adding an employer name to the person's name in trailers (e.g. John Doe (Acme) <[email protected]>). The b4 trailers command will re-write the trailers with quotes around the name. email.utils.formataddr() does that as it is necessary for email headers, but it is not necessary for trailers. As we already have the original value, just use it.

This effectively reverts commit 832010c4d50b ("trailers: normalize address after parsing") and all the follow-up commits touching this code. Maintaining quoting or lack of seems more important and common than oddball 'mailto:' links.

---
 src/b4/__init__.py | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
src/b4/__init__.py +1 -4
index 99ece6484d8e..de324d0f714b 100644
@@ -1062,10 +1062,7 @@ class LoreTrailer:
             elif re.search(r'\S+@\S+\.\S+', value):
                 self.type = 'person'
                 self.addr = email.utils.parseaddr(value)
-                # Normalize the value with parsed data
-                if self.addr[0] or self.addr[1]:
-                    self.value = email.utils.formataddr(self.addr)
-                else:
+                if not (self.addr[0] or self.addr[1]):
                     self.type = 'unknown'
             else:
                 self.type = 'unknown'
Signature · 1 line
2.47.2
#1 lore raw
Quoted 13 lines · Rob Herring (Arm)

A somewhat common pattern is adding an employer name to the person's name in trailers (e.g. John Doe (Acme) <[email protected]>). The b4 trailers command will re-write the trailers with quotes around the name. email.utils.formataddr() does that as it is necessary for email headers, but it is not necessary for trailers. As we already have the original value, just use it.

This effectively reverts commit 832010c4d50b ("trailers: normalize address after parsing") and all the follow-up commits touching this code. Maintaining quoting or lack of seems more important and common than oddball 'mailto:' links.

Quoted 5 lines
---
 src/b4/__init__.py | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Ping!

Quoted 20 lines
src/b4/__init__.py +1 -5
index 99ece6484d8e..de324d0f714b 100644
@@ -1062,10 +1062,7 @@ class LoreTrailer:
             elif re.search(r'\S+@\S+\.\S+', value):
                 self.type = 'person'
                 self.addr = email.utils.parseaddr(value)
-                # Normalize the value with parsed data
-                if self.addr[0] or self.addr[1]:
-                    self.value = email.utils.formataddr(self.addr)
-                else:
+                if not (self.addr[0] or self.addr[1]):
                     self.type = 'unknown'
             else:
                 self.type = 'unknown'
--

2.47.2

#2 lore raw
In reply to Rob Herring (Arm)
Quoted 11 lines · Rob Herring (Arm)

A somewhat common pattern is adding an employer name to the person's name in trailers (e.g. John Doe (Acme) <[email protected]>). The b4 trailers command will re-write the trailers with quotes around the name. email.utils.formataddr() does that as it is necessary for email headers, but it is not necessary for trailers. As we already have the original value, just use it.

This effectively reverts commit 832010c4d50b ("trailers: normalize address after parsing") and all the follow-up commits touching this code. Maintaining quoting or lack of seems more important and common than oddball 'mailto:' links.

I didn't take this directly, because I didn't want to completely reverse that commit, but the change in the latest master should do what you want.

Thank you for the report.

-K