From: Stephan Bosch Date: Sun, 4 Nov 2018 18:09:41 +0000 (+0100) Subject: lib-smtp: smtp-address - Allow parsing address from username that contains space... X-Git-Tag: 2.3.9~129 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=06fd0f068c45d176b14b54707f1a9be3b8cc0083;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: smtp-address - Allow parsing address from username that contains space, double quote or backslash. 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. --- diff --git a/src/lib-smtp/smtp-address.c b/src/lib-smtp/smtp-address.c index 1c64c6ad1f..cfb9062ff1 100644 --- a/src/lib-smtp/smtp-address.c +++ b/src/lib-smtp/smtp-address.c @@ -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; diff --git a/src/lib-smtp/test-smtp-address.c b/src/lib-smtp/test-smtp-address.c index b23dd89167..13ebaddb1d 100644 --- a/src/lib-smtp/test-smtp-address.c +++ b/src/lib-smtp/test-smtp-address.c @@ -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 =