Skip to content

Commit

Permalink
lib-mail: message_address_write() - Write empy username as ""
Browse files Browse the repository at this point in the history
We can't output <@Domain> because that conflicts with the <@route:...>
syntax. Also ""@Domain seems to be a valid address.
  • Loading branch information
sirainen authored and GitLab committed Jun 7, 2017
1 parent 5a8ee85 commit dc8c1e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/lib-mail/message-address.c
Expand Up @@ -468,7 +468,10 @@ void message_address_write(string_t *str, const struct message_address *addr)
str_append(str, addr->route);
str_append_c(str, ':');
}
str_append_maybe_escape(str, addr->mailbox, FALSE);
if (addr->mailbox[0] == '\0')
str_append(str, "\"\"");
else
str_append_maybe_escape(str, addr->mailbox, FALSE);
if (addr->domain[0] != '\0') {
str_append_c(str, '@');
str_append(str, addr->domain);
Expand Down
4 changes: 3 additions & 1 deletion src/lib-mail/test-message-address.c
Expand Up @@ -26,6 +26,8 @@ static void test_message_address(void)
{ NULL, NULL, NULL, "user", "domain", FALSE } },
{ "<user@domain>", NULL,
{ NULL, NULL, NULL, "user", "domain", FALSE } },
{ "<\"\"@domain>", "<\"\"@domain>",
{ NULL, NULL, NULL, "", "domain", FALSE } },
{ "foo bar <user@domain>", "\"foo bar\" <user@domain>",
{ NULL, "foo bar", NULL, "user", "domain", FALSE } },
{ "\"foo bar\" <user@domain>", NULL,
Expand All @@ -44,7 +46,7 @@ static void test_message_address(void)
{ NULL, "hello", NULL, "user", "", TRUE } },
{ "hello <user>", "hello <user>",
{ NULL, "hello", NULL, "user", "", TRUE } },
{ "@domain", "<@domain>",
{ "@domain", "<\"\"@domain>",
{ NULL, NULL, NULL, "", "domain", TRUE } },
};
static struct message_address group_prefix = {
Expand Down

0 comments on commit dc8c1e7

Please sign in to comment.