Message ID | 20241027-trailer-special-chars-v2-3-e963f78b3ef8@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Handle patch trailers with special characters | expand |
diff --git a/src/b4/__init__.py b/src/b4/__init__.py index 5115a9cd9b8746f84eb104a2be69fe121724167e..cf112e3bce2911c78cff18aac267608f796957ab 100644 --- a/src/b4/__init__.py +++ b/src/b4/__init__.py @@ -1063,8 +1063,10 @@ def __init__(self, name: Optional[str] = None, value: Optional[str] = None, exti # Normalize the value with parsed data if self.addr[0]: self.value = f'{self.addr[0]} <{self.addr[1]}>' - else: + elif self.addr[1]: self.value = self.addr[1] + else: + self.type = 'unknown' else: self.type = 'unknown' self.lname = self.name.lower()
A patch trailer with an improperly formatted email parses to an empty string. For example see the linked github issue, where a trailer's display name contains an unquoted comma. As patch trailers are often hand written this can happen frequently. Try to gracefully handle this case by checking if an email parses correctly, and if it doesn't fallback to displaying it verbatim. Fixes: https://github.com/mricon/b4/issues/50 Signed-off-by: Brandon Maier <brandon.maier@gmail.com> --- src/b4/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)