Skip to content

Commit

Permalink
lib-mail: message_address_write() - Don't write empty <>
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed Jun 12, 2017
1 parent 258c8f2 commit 880012f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
27 changes: 16 additions & 11 deletions src/lib-mail/message-address.c
Expand Up @@ -467,19 +467,24 @@ void message_address_write(string_t *str, const struct message_address *addr)
str_append(str, addr->name);
else
str_append_maybe_escape(str, addr->name, TRUE);
str_append_c(str, ' ');
}
str_append_c(str, '<');
if (addr->route != NULL) {
str_append(str, addr->route);
str_append_c(str, ':');
}
str_append_maybe_escape(str, addr->mailbox, FALSE);
if (addr->domain[0] != '\0') {
str_append_c(str, '@');
str_append(str, addr->domain);
if (addr->route != NULL ||
addr->mailbox[0] != '\0' ||
addr->domain[0] != '\0') {
if (addr->name != NULL && addr->name[0] != '\0')
str_append_c(str, ' ');
str_append_c(str, '<');
if (addr->route != NULL) {
str_append(str, addr->route);
str_append_c(str, ':');
}
str_append_maybe_escape(str, addr->mailbox, FALSE);
if (addr->domain[0] != '\0') {
str_append_c(str, '@');
str_append(str, addr->domain);
}
str_append_c(str, '>');
}
str_append_c(str, '>');
}

addr = addr->next;
Expand Down
2 changes: 1 addition & 1 deletion src/lib-mail/test-message-address.c
Expand Up @@ -38,7 +38,7 @@ static void test_message_address(void)
{ NULL, NULL, "@route,@route2", "user", "domain", FALSE } },
{ "hello <@route ,@route2:user@domain>", "hello <@route,@route2:user@domain>",
{ NULL, "hello", "@route,@route2", "user", "domain", FALSE } },
{ "hello", "hello <>",
{ "hello", "hello",
{ NULL, "hello", NULL, "", "", TRUE } },
{ "user (hello)", "hello <user>",
{ NULL, "hello", NULL, "user", "", TRUE } },
Expand Down

0 comments on commit 880012f

Please sign in to comment.