dovecot-1.0: rfc822_parse_quoted_string(): Handle folding whites...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Oct 23 18:59:04 EEST 2008
details: http://hg.dovecot.org/dovecot-1.0/rev/e19d44320065
changeset: 5569:e19d44320065
user: Timo Sirainen <tss at iki.fi>
date: Thu Oct 23 18:59:00 2008 +0300
description:
rfc822_parse_quoted_string(): Handle folding whitespace.
diffstat:
1 file changed, 20 insertions(+), 12 deletions(-)
src/lib-mail/rfc822-parser.c | 32 ++++++++++++++++++++------------
diffs (50 lines):
diff -r 2dc3a5678fe5 -r e19d44320065 src/lib-mail/rfc822-parser.c
--- a/src/lib-mail/rfc822-parser.c Mon Sep 08 16:56:13 2008 +0300
+++ b/src/lib-mail/rfc822-parser.c Thu Oct 23 18:59:00 2008 +0300
@@ -200,26 +200,34 @@ int rfc822_parse_quoted_string(struct rf
int rfc822_parse_quoted_string(struct rfc822_parser_context *ctx, string_t *str)
{
const unsigned char *start;
+ size_t len;
i_assert(*ctx->data == '"');
ctx->data++;
for (start = ctx->data; ctx->data != ctx->end; ctx->data++) {
- if (*ctx->data == '"') {
+ switch (*ctx->data) {
+ case '"':
str_append_n(str, start, ctx->data - start);
ctx->data++;
return rfc822_skip_lwsp(ctx);
- }
-
- if (*ctx->data != '\\')
- continue;
-
- ctx->data++;
- if (ctx->data == ctx->end)
- return -1;
-
- str_append_n(str, start, ctx->data - start);
- start = ctx->data;
+ case '\n':
+ /* folding whitespace, remove the (CR)LF */
+ len = ctx->data - start;
+ if (len > 0 && start[len-1] == '\r')
+ len--;
+ str_append_n(str, start, len);
+ start = ctx->data + 1;
+ break;
+ case '\\':
+ ctx->data++;
+ if (ctx->data == ctx->end)
+ return -1;
+
+ str_append_n(str, start, ctx->data - start);
+ start = ctx->data;
+ break;
+ }
}
/* missing '"' */
More information about the dovecot-cvs
mailing list