[PATCH v2 5/7] lib-mail: parse_mailbox: Set display name instead mailbox when parsing failed
Pali Rohár
pali.rohar at gmail.com
Sun Jun 5 13:48:18 UTC 2016
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 | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/lib-mail/message-address.c b/src/lib-mail/message-address.c
index 93b7c83..54d4ee1 100644
--- a/src/lib-mail/message-address.c
+++ b/src/lib-mail/message-address.c
@@ -205,6 +205,10 @@ 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 && ctx->addr.mailbox && !ctx->addr.domain) {
+ ctx->addr.name = ctx->addr.mailbox;
+ ctx->addr.mailbox = NULL;
+ }
}
if (ret < 0)
--
1.7.9.5
More information about the dovecot
mailing list