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.3.0.rc1~3539 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=91fdb25b5a77defecbbc0cb9b7f15f28e9dab1f0;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 93b7c83093..5136f90d8e 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)