Skip to content

Commit f0f501b

Browse files
committed
API: Properly quote name
RFC 5322, "Internet Message Format" specifies in §3.4 Address Specification that commas separate the addresses in a list. But some people use comma in their name: pwclient list -S "$series_id" -f '%{submitter}' Surname, Name <foo@example.com> Using passing the output to git send-email causes it to fail (at least dovecot refuses to send): git send-email --to="Surname, Name <foo@example.com>" ... 5.5.4 Invalid TO: Missing domain Quoting name helps: pwclient list -S "$series_id" -f '%{submitter}' "Surname, Name" <foo@example.com> git send-email --to='"Surname, Name" <foo@example.com>" ... To: "Surname, Name" <foo@example.com> Result: 250 Signed-off-by: Petr Vorel <pvorel@suse.cz>
1 parent e6c42b2 commit f0f501b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎pwclient/api.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,11 @@ def _format_person(person):
752752
return ''
753753

754754
if person['name']:
755-
return f"{person['name']} <{person['email']}>"
755+
name = person['name']
756+
# quoting names with comma (unless already quoted)
757+
if ',' in name and not '"' in name:
758+
name = f'"{name}"'
759+
return f"{name} <{person['email']}>"
756760
return person['email']
757761

758762
def _format_user(user):

0 commit comments

Comments
 (0)