From: Stephan Bosch Date: Sun, 8 Apr 2018 10:13:16 +0000 (+0200) Subject: lib-smtp: address parser: Do not allow source route for path with omitted brackets. X-Git-Tag: 2.3.2.rc1~152 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0f73d2443cc6aafc0f26e6d9d84117f7bbff61d1;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: address parser: Do not allow source route for path with omitted brackets. Parse it strictly as a Mailbox, which makes more sense. --- diff --git a/src/lib-smtp/smtp-address.c b/src/lib-smtp/smtp-address.c index 72e5c08bfb..b37aaaad06 100644 --- a/src/lib-smtp/smtp-address.c +++ b/src/lib-smtp/smtp-address.c @@ -195,7 +195,7 @@ smtp_parse_path(struct smtp_address_parser *aparser, } /* [ A-d-l ":" ] */ - if ((sret=smtp_parse_source_route(parser)) < 0) + if (aparser->path && (sret=smtp_parse_source_route(parser)) < 0) return -1; /* Mailbox */ diff --git a/src/lib-smtp/test-smtp-address.c b/src/lib-smtp/test-smtp-address.c index 6d937db991..30e6499139 100644 --- a/src/lib-smtp/test-smtp-address.c +++ b/src/lib-smtp/test-smtp-address.c @@ -178,6 +178,11 @@ valid_path_parse_tests[] = { .input = "<@otherdomain.tld,@yetanotherdomain.tld:user@domain.tld>", .address = { .localpart = "user", .domain = "domain.tld" }, .output = "" + },{ + .input = "user@domain.tld", + .flags = SMTP_ADDRESS_PARSE_FLAG_BRACKETS_OPTIONAL, + .address = { .localpart = "user", .domain = "domain.tld" }, + .output = "" } }; @@ -586,6 +591,9 @@ invalid_path_parse_tests[] = { }, { .input = "email@example..com", .flags = SMTP_ADDRESS_PARSE_FLAG_BRACKETS_OPTIONAL + }, { + .input = "@otherdomain.tld,@yetanotherdomain.tld:user@domain.tld", + .flags = SMTP_ADDRESS_PARSE_FLAG_BRACKETS_OPTIONAL }, { .input = "<>", }, {