--- 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);
