]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: parse_mailbox: Set display name instead mailbox when parsing failed
authorPali Rohár <pali.rohar@gmail.com>
Sun, 5 Jun 2016 13:48:18 +0000 (15:48 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 12 Jun 2017 13:57:00 +0000 (16:57 +0300)
It does not make sense to set mailbox without domain on incorrect input.
Rather set display name which is more likely useable value.

Test case:

  test

is parsed as:

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

src/lib-mail/message-address.c

index 2a234c8f4b7545e0067924ae613d915a5ec1405b..69dc59e9db62fa0f84d5bb7ff347ff78996efcac 100644 (file)
@@ -205,6 +205,11 @@ static int parse_mailbox(struct message_address_parser_context *ctx)
                /* nope, should be addr-spec */
                ctx->parser.data = start;
                ret = parse_addr_spec(ctx);
+               if (ctx->addr.invalid_syntax && ctx->addr.name == NULL &&
+                   ctx->addr.mailbox == NULL && ctx->addr.domain == NULL) {
+                       ctx->addr.name = ctx->addr.mailbox;
+                       ctx->addr.mailbox = NULL;
+               }
        }
 
        if (ret < 0)