Avoid quoting email names in trailers
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
@@ -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
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
Cc Brandon Maier <[email protected]>Signed-off-by Rob Herring (Arm) <[email protected]>--- src/b4/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Ping!
Quoted 20 lines
src/b4/__init__.py +1
-5@@ -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
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