Skip to content

Commit

Permalink
lib-mail: message_address_write: Fix generating empty group list
Browse files Browse the repository at this point in the history
Empty group list ends with ": " not with ", ".

Test case:

  { { name = NULL, mailbox = "group", domain = NULL }, { name = NULL, mailbox = NULL, domain = NULL } }

converts to:

  group:;
  • Loading branch information
pali authored and sirainen committed Jun 12, 2017
1 parent 410ef08 commit 3ca9015
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib-mail/message-address.c
Expand Up @@ -341,6 +341,7 @@ message_address_parse(pool_t pool, const unsigned char *data, size_t size,

void message_address_write(string_t *str, const struct message_address *addr)
{
const char *tmp;
bool first = TRUE, in_group = FALSE;

/* a) mailbox@domain
Expand All @@ -366,7 +367,12 @@ void message_address_write(string_t *str, const struct message_address *addr)
i_assert(addr->mailbox == NULL);

/* cut out the ", " */
str_truncate(str, str_len(str)-2);
tmp = str_c(str)+str_len(str)-2;
i_assert((tmp[0] == ',' || tmp[0] == ':') && tmp[1] == ' ');
if (tmp[0] == ',' && tmp[1] == ' ')
str_truncate(str, str_len(str)-2);
else if (tmp[0] == ':' && tmp[1] == ' ')
str_truncate(str, str_len(str)-1);
str_append_c(str, ';');
}

Expand Down

0 comments on commit 3ca9015

Please sign in to comment.