]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: address parser: Do not allow source route for path with omitted brackets.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sun, 8 Apr 2018 10:13:16 +0000 (12:13 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 27 Apr 2018 10:40:00 +0000 (13:40 +0300)
Parse it strictly as a Mailbox, which makes more sense.

src/lib-smtp/smtp-address.c
src/lib-smtp/test-smtp-address.c

index 72e5c08bfb31b394f63f68a45ff51489e3d38be5..b37aaaad06abb4a4d4bd933f6ec99b01d01e5771 100644 (file)
@@ -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 */
index 6d937db991188f9cf0f4341babe765a6381172b6..30e649913978b526627983d05e1e8d6a6ba7b982 100644 (file)
@@ -178,6 +178,11 @@ valid_path_parse_tests[] = {
                .input = "<@otherdomain.tld,@yetanotherdomain.tld:user@domain.tld>",
                .address = { .localpart = "user", .domain = "domain.tld" },
                .output = "<user@domain.tld>"
+       },{
+               .input = "user@domain.tld",
+               .flags = SMTP_ADDRESS_PARSE_FLAG_BRACKETS_OPTIONAL,
+               .address = { .localpart = "user", .domain = "domain.tld" },
+               .output = "<user@domain.tld>"
        }
 };
 
@@ -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 = "<>",
        }, {