]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: message_address_write: Fix generating group list with empty name
authorPali Rohár <pali.rohar@gmail.com>
Sun, 5 Jun 2016 13:48:15 +0000 (15:48 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 12 Jun 2017 13:56:32 +0000 (16:56 +0300)
Empty name for group list must be quoted.

Test case:

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

converts to:

  "":;

src/lib-mail/message-address.c

index dc938863c971d48f7a6f06af25b4352bb35a8d08..225d1a8103a1b658cae79dd4f1821f862cc49a66 100644 (file)
@@ -358,8 +358,12 @@ void message_address_write(string_t *str, const struct message_address *addr)
                        if (!in_group) {
                                /* beginning of group. mailbox is the group
                                   name, others are NULL. */
-                               if (addr->mailbox != NULL)
+                               if (addr->mailbox != NULL && *addr->mailbox != '\0') {
                                        str_append(str, addr->mailbox);
+                               } else {
+                                       /* empty group name needs to be quoted */
+                                       str_append(str, "\"\"");
+                               }
                                str_append(str, ": ");
                                first = TRUE;
                        } else {