[Dovecot] Another address-spec problem
I've had complaints from users about "MISSING_DOMAIN" in header fields and I've tracked it down to having "." in an unquoted display name.
By my reading of RFC2822 (especially section 4.1)
A N Other a.n.other@somewhere.org "A. N. Other" a.n.other@somewhere.org
are legal, but
A. N. Other a.n.other@somewhere.org
is "obsolete", but should be supported by the server (no clients should do it).
I think the relevant syntax is
phrase = 1*word / obs-phrase
word = atom / quoted-string
obs-phrase = word *(word / "." / CFWS)
and rfc822_parse_phrase() should be modified to cope with "obs-phrase".
I'll have a go, but if Timo or anybody knows how to do it properly, that would be better!
Chris
-- --+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+- Christopher Wakelin, c.d.wakelin@reading.ac.uk IT Services Centre, The University of Reading, Tel: +44 (0)118 378 8439 Whiteknights, Reading, RG6 2AF, UK Fax: +44 (0)118 975 3094
Here's a first attempt at a patch against Dovecot-1.0-stable. It
basically allows "." in the words as long as it's not the first
character of the first word.
The patch should work with Dovecot-1.0-alpha2 with very slight
modification (Timo put some comments in rfc822-parser.h which breaks the
diff).
So
A. N. Other
I've had complaints from users about "MISSING_DOMAIN" in header fields and I've tracked it down to having "." in an unquoted display name.
By my reading of RFC2822 (especially section 4.1)
A N Other
"A. N. Other" are legal, but
A. N. Other
is "obsolete", but should be supported by the server (no clients should do it).
I think the relevant syntax is
phrase = 1*word / obs-phrase word = atom / quoted-string obs-phrase = word *(word / "." / CFWS)
and rfc822_parse_phrase() should be modified to cope with "obs-phrase".
I'll have a go, but if Timo or anybody knows how to do it properly, that would be better!
Chris
-- --+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+- Christopher Wakelin, c.d.wakelin@reading.ac.uk IT Services Centre, The University of Reading, Tel: +44 (0)118 378 8439 Whiteknights, Reading, RG6 2AF, UK Fax: +44 (0)118 975 3094 --- dovecot-1.0-stable/src/lib-mail/rfc822-parser.c.orig Tue Feb 8 10:36:06 2005 +++ dovecot-1.0-stable/src/lib-mail/rfc822-parser.c Thu Sep 22 15:12:35 2005 @@ -134,6 +134,27 @@ return 0; } +int rfc822_parse_atom_or_dot(struct rfc822_parser_context *ctx, string_t *str) +{ + const unsigned char *start; + + /* + atom = [CFWS] 1*atext [CFWS] + atext = + ; Any character except controls, SP, and specials. + */ + for (start = ctx->data; ctx->data != ctx->end; ctx->data++) { + if (IS_ATEXT(*ctx->data) || *ctx->data == '.') + continue; + + str_append_n(str, start, ctx->data - start); + return rfc822_skip_lwsp(ctx); + } + + str_append_n(str, start, ctx->data - start); + return 0; +} + int rfc822_parse_dot_atom(struct rfc822_parser_context *ctx, string_t *str) { const unsigned char *start; @@ -205,15 +226,26 @@ { int ret; + /* + phrase = 1*word / obs-phrase + word = atom / quoted-string + obs-phrase = word *(word / "." / CFWS) + */ + + if (*ctx->data == '.') + return -1; + for (;;) { if (*ctx->data == '"') ret = rfc822_parse_quoted_string(ctx, str); else - ret = rfc822_parse_atom(ctx, str); + ret = rfc822_parse_atom_or_dot(ctx, str); + if (ret <= 0) return ret; - if (!IS_ATEXT(*ctx->data) && *ctx->data != '"') + if (!IS_ATEXT(*ctx->data) && *ctx->data != '"' + && *ctx->data != '.') break; str_append_c(str, ' '); } --- dovecot-1.0-stable/src/lib-mail/rfc822-parser.h.orig Tue Feb 8 10:36:06 2005 +++ dovecot-1.0-stable/src/lib-mail/rfc822-parser.h Thu Sep 22 12:31:17 2005 @@ -13,6 +13,7 @@ int rfc822_skip_comment(struct rfc822_parser_context *ctx); int rfc822_skip_lwsp(struct rfc822_parser_context *ctx); int rfc822_parse_atom(struct rfc822_parser_context *ctx, string_t *str); +int rfc822_parse_atom_or_dot(struct rfc822_parser_context *ctx, string_t *str); int rfc822_parse_dot_atom(struct rfc822_parser_context *ctx, string_t *str); int rfc822_parse_quoted_string(struct rfc822_parser_context *ctx, string_t *str);
On Thu, 2005-09-22 at 17:48 +0100, Chris Wakelin wrote:
Here's a first attempt at a patch against Dovecot-1.0-stable. It basically allows "." in the words as long as it's not the first character of the first word.
The patch should work with Dovecot-1.0-alpha2 with very slight modification (Timo put some comments in rfc822-parser.h which breaks the diff).
Thanks, committed. I didn't put it in the header file since nothing else probably wants to use it.
participants (2)
-
Chris Wakelin
-
Timo Sirainen