From: Timo Sirainen Date: Wed, 7 Jun 2017 09:35:35 +0000 (+0300) Subject: lib-mail: message_address_write() - Don't write empty <> X-Git-Tag: 2.3.0.rc1~1497 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ffc8c62c46a087a4d30f8704b0a8440d3e4d8916;p=thirdparty%2Fdovecot%2Fcore.git lib-mail: message_address_write() - Don't write empty <> --- diff --git a/src/lib-mail/message-address.c b/src/lib-mail/message-address.c index 7fc99d054a..a1e0977b36 100644 --- a/src/lib-mail/message-address.c +++ b/src/lib-mail/message-address.c @@ -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; diff --git a/src/lib-mail/test-message-address.c b/src/lib-mail/test-message-address.c index 05db36e3fa..1604104f5f 100644 --- a/src/lib-mail/test-message-address.c +++ b/src/lib-mail/test-message-address.c @@ -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 ", { NULL, "hello", NULL, "user", "", TRUE } },