]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-address - Allow parsing address from username that contains space...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sun, 4 Nov 2018 18:09:41 +0000 (19:09 +0100)
committerStephan Bosch <stephan.bosch@open-xchange.com>
Fri, 4 Oct 2019 11:59:35 +0000 (13:59 +0200)
Not allowing double quote and backslash was a bug, while space was explicitly
disallowed. However, these characters can be used in an RFC 5321 address when
inside a quoted string, so there is no reason to disallow those.

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

index 1c64c6ad1f89b29e1d51f60739566d8ac16f3f17..cfb9062ff1471587eea767ec7cdbcfcda7381d35 100644 (file)
@@ -256,7 +256,8 @@ static int smtp_parse_username(struct smtp_address_parser *aparser)
                /* check whether the resulting localpart could be encoded as
                   quoted string */
                for (p = parser->cur; p < dp; p++) {
-                       if (!smtp_char_is_qtext(*p) || *p == ' ') {
+                       if (!smtp_char_is_qtext(*p) &&
+                           !smtp_char_is_qpair(*p)) {
                                parser->error =
                                        "Invalid character in user name";
                                return -1;
index b23dd891671469f2c9148e007afa4f14a4fd7dc6..13ebaddb1da1aef0cdc75895b5e8b2c97847786b 100644 (file)
@@ -348,6 +348,21 @@ valid_username_parse_tests[] = {
                .address = { .localpart = "user@frop", .domain = "domain.tld" },
                .output = "\"user@frop\"@domain.tld"
        },
+       {
+               .input = "user frop@domain.tld",
+               .address = { .localpart = "user frop", .domain = "domain.tld" },
+               .output = "\"user frop\"@domain.tld"
+       },
+       {
+               .input = "user\"frop@domain.tld",
+               .address = { .localpart = "user\"frop", .domain = "domain.tld" },
+               .output = "\"user\\\"frop\"@domain.tld"
+       },
+       {
+               .input = "user\\frop@domain.tld",
+               .address = { .localpart = "user\\frop", .domain = "domain.tld" },
+               .output = "\"user\\\\frop\"@domain.tld"
+       },
        {
                .input = "user@127.0.0.1",
                .address = { .localpart = "user", .domain = "127.0.0.1" },
@@ -870,11 +885,8 @@ invalid_username_parse_tests[] = {
                .input = "frop@$%^$%^.tld",
        },
        {
-               .input = "fr    op@domain.tld",
-       },
-       {
-               .input = "f r o p@domain.tld",
-       },
+               .input = "fr\top@domain.tld",
+       }
 };
 
 unsigned int invalid_username_parse_test_count =