]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: message_address_parse() - don't stop at <> when parsing address lists
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 7 Jun 2017 12:21:10 +0000 (15:21 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 12 Jun 2017 14:05:32 +0000 (17:05 +0300)
And similarly don't stop at <@domain>

src/lib-mail/message-address.c

index 32c41f8e424c1b8d9cd57d1fd41ea364922e7efa..ce1f30575d42007eb96aebdc36edd927d9be2280 100644 (file)
@@ -153,18 +153,25 @@ static int parse_angle_addr(struct message_address_parser_context *ctx)
                if (parse_domain_list(ctx) <= 0 || *ctx->parser.data != ':') {
                        if (ctx->fill_missing)
                                ctx->addr.route = "INVALID_ROUTE";
-                       return -1;
+                       if (ctx->parser.data == ctx->parser.end)
+                               return -1;
+                       /* try to continue anyway */
+               } else {
+                       ctx->parser.data++;
                }
-               ctx->parser.data++;
                if ((ret = rfc822_skip_lwsp(&ctx->parser)) <= 0)
                        return ret;
        }
 
-       if ((ret = parse_local_part(ctx)) <= 0)
-               return ret;
-       if (*ctx->parser.data == '@') {
-               if ((ret = parse_domain(ctx)) <= 0)
+       if (*ctx->parser.data == '>') {
+               /* <> address isn't valid */
+       } else {
+               if ((ret = parse_local_part(ctx)) <= 0)
                        return ret;
+               if (*ctx->parser.data == '@') {
+                       if ((ret = parse_domain(ctx)) <= 0)
+                               return ret;
+               }
        }
 
        if (*ctx->parser.data != '>')