[dovecot-cvs] dovecot/src/lib-mail rfc822-parser.c,1.3,1.4
cras at dovecot.org
cras at dovecot.org
Fri Sep 23 15:03:50 EEST 2005
Update of /var/lib/cvs/dovecot/src/lib-mail
In directory talvi:/tmp/cvs-serv19530
Modified Files:
rfc822-parser.c
Log Message:
Parse obs-phrase correctly. Patch by Chris Wakelin
Index: rfc822-parser.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/rfc822-parser.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- rfc822-parser.c 5 Jun 2005 19:32:33 -0000 1.3
+++ rfc822-parser.c 23 Sep 2005 12:03:48 -0000 1.4
@@ -230,19 +230,55 @@
return -1;
}
+static 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.
+
+ The difference between this function and rfc822_parse_dot_atom()
+ is that this doesn't just silently skip over all the whitespace.
+ */
+ 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_phrase(struct rfc822_parser_context *ctx, string_t *str)
{
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, ' ');
}
More information about the dovecot-cvs
mailing list