dovecot-1.2: rfc822_parse_quoted_string(): Handle folding whites...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Oct 23 18:58:46 EEST 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/836c8c2b87f5
changeset: 8318:836c8c2b87f5
user: Timo Sirainen <tss at iki.fi>
date: Thu Oct 23 18:58:22 2008 +0300
description:
rfc822_parse_quoted_string(): Handle folding whitespace.
diffstat:
1 file changed, 19 insertions(+), 11 deletions(-)
src/lib-mail/rfc822-parser.c | 30 +++++++++++++++++++-----------
diffs (49 lines):
diff -r 62e134c25a5e -r 836c8c2b87f5 src/lib-mail/rfc822-parser.c
--- a/src/lib-mail/rfc822-parser.c Thu Oct 23 18:27:20 2008 +0300
+++ b/src/lib-mail/rfc822-parser.c Thu Oct 23 18:58:22 2008 +0300
@@ -207,26 +207,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);
+ 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;
}
-
- if (*ctx->data != '\\')
- continue;
-
- ctx->data++;
- if (ctx->data == ctx->end)
- return -1;
-
- str_append_n(str, start, ctx->data - start);
- start = ctx->data;
}
/* missing '"' */
More information about the dovecot-cvs
mailing list