]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: message_address_parse() - Add INVALID_ROUTE/SYNTAX_ERROR only if fill_missi...
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 7 Jun 2017 09:58:21 +0000 (12:58 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 12 Jun 2017 14:05:32 +0000 (17:05 +0300)
This allows message_address_write() to write the parsed invalid address in a
way that at least somewhat resembles the original input.

src/lib-mail/message-address.c
src/lib-mail/test-message-address.c

index 8fa38b2e1a1679e3a0624b6e0f820d246f873e7e..ccb1392a7a00ea75fd826b525d6dd7a371b19e48 100644 (file)
@@ -151,7 +151,8 @@ static int parse_angle_addr(struct message_address_parser_context *ctx)
 
        if (*ctx->parser.data == '@') {
                if (parse_domain_list(ctx) <= 0 || *ctx->parser.data != ':') {
-                       ctx->addr.route = "INVALID_ROUTE";
+                       if (ctx->fill_missing)
+                               ctx->addr.route = "INVALID_ROUTE";
                        return -1;
                }
                ctx->parser.data++;
@@ -191,7 +192,8 @@ static int parse_name_addr(struct message_address_parser_context *ctx)
        }
        if (parse_angle_addr(ctx) < 0) {
                /* broken */
-               ctx->addr.domain = "SYNTAX_ERROR";
+               if (ctx->fill_missing)
+                       ctx->addr.domain = "SYNTAX_ERROR";
                ctx->addr.invalid_syntax = TRUE;
        }
        return ctx->parser.data != ctx->parser.end;
index 473acfab95d1c418b91c792cff8a5534b2a5ad81..4bcd3b65764aae3cdcf5eeadfadf0816de795043 100644 (file)
@@ -26,6 +26,8 @@ static void test_message_address(void)
                  { NULL, NULL, NULL, "user", "domain", FALSE } },
                { "<user@domain>", NULL,
                  { NULL, NULL, NULL, "user", "domain", FALSE } },
+               { "<@route>", "<@route:\"\">",
+                 { NULL, NULL, "@route", "", "", TRUE } },
                { "<\"\"@domain>", "<\"\"@domain>",
                  { NULL, NULL, NULL, "", "domain", FALSE } },
                { "foo bar <user@domain>", "\"foo bar\" <user@domain>",