Skip to content

Commit

Permalink
lib-mail: parse_mailbox: Set display name instead mailbox when parsin…
Browse files Browse the repository at this point in the history
…g failed

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 }
  • Loading branch information
pali authored and sirainen committed Jun 12, 2017
1 parent bde3ab4 commit 7e9b80a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib-mail/message-address.c
Expand Up @@ -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)
Expand Down

0 comments on commit 7e9b80a

Please sign in to comment.