Skip to content

Commit

Permalink
lib-mail: message_address_write() - Always write <user@domain> as output
Browse files Browse the repository at this point in the history
This is the standard format nowadays, so don't convert <user@domain> into
plain user@domain.
  • Loading branch information
sirainen authored and GitLab committed Jun 7, 2017
1 parent ffc8c62 commit 5a8ee85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
12 changes: 1 addition & 11 deletions src/lib-mail/message-address.c
Expand Up @@ -444,18 +444,8 @@ void message_address_write(string_t *str, const struct message_address *addr)
}

in_group = !in_group;
} else if ((addr->name == NULL || *addr->name == '\0') &&
addr->route == NULL) {
/* no name and no route. use only mailbox@domain */
i_assert(addr->mailbox != NULL);

str_append_maybe_escape(str, addr->mailbox, FALSE);
if (addr->domain[0] != '\0') {
str_append_c(str, '@');
str_append(str, addr->domain);
}
} else {
/* name and/or route. use full <mailbox@domain> Name */
/* "Display Name" <mailbox@domain> */
i_assert(addr->mailbox != NULL);

if (addr->name != NULL) {
Expand Down
6 changes: 3 additions & 3 deletions src/lib-mail/test-message-address.c
Expand Up @@ -22,9 +22,9 @@ static void test_message_address(void)
const char *wanted_output;
struct message_address addr;
} tests[] = {
{ "user@domain", NULL,
{ "user@domain", "<user@domain>",
{ NULL, NULL, NULL, "user", "domain", FALSE } },
{ "<user@domain>", "user@domain",
{ "<user@domain>", NULL,
{ NULL, NULL, NULL, "user", "domain", FALSE } },
{ "foo bar <user@domain>", "\"foo bar\" <user@domain>",
{ NULL, "foo bar", NULL, "user", "domain", FALSE } },
Expand All @@ -44,7 +44,7 @@ static void test_message_address(void)
{ NULL, "hello", NULL, "user", "", TRUE } },
{ "hello <user>", "hello <user>",
{ NULL, "hello", NULL, "user", "", TRUE } },
{ "@domain", NULL,
{ "@domain", "<@domain>",
{ NULL, NULL, NULL, "", "domain", TRUE } },
};
static struct message_address group_prefix = {
Expand Down

0 comments on commit 5a8ee85

Please sign in to comment.