From: Pali Rohár Date: Sun, 5 Jun 2016 13:48:18 +0000 (+0200) Subject: lib-mail: parse_mailbox: Set display name instead mailbox when parsing failed X-Git-Tag: 2.2.31.rc1~102 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7e9b80a019b6e96fe40a93a4f813a3b2d058809b;p=thirdparty%2Fdovecot%2Fcore.git lib-mail: parse_mailbox: Set display name instead mailbox when parsing 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 } --- diff --git a/src/lib-mail/message-address.c b/src/lib-mail/message-address.c index 2a234c8f4b..69dc59e9db 100644 --- a/src/lib-mail/message-address.c +++ b/src/lib-mail/message-address.c @@ -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)