Mercurial > dovecot > core-2.2
changeset 18343:308a97126244
lib-mail: Added HEADER_FILTER_CRLF_PRESERVE flag to istream-header-filter.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 12 Mar 2015 19:39:03 +0200 |
parents | 34862aea421d |
children | d592417ec815 |
files | src/lib-mail/istream-header-filter.c src/lib-mail/istream-header-filter.h |
diffstat | 2 files changed, 15 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-mail/istream-header-filter.c Thu Mar 12 17:41:09 2015 +0200 +++ b/src/lib-mail/istream-header-filter.c Thu Mar 12 19:39:03 2015 +0200 @@ -33,6 +33,7 @@ unsigned int header_parsed:1; unsigned int exclude:1; unsigned int crlf:1; + unsigned int crlf_preserve:1; unsigned int hide_body:1; unsigned int add_missing_eoh:1; unsigned int end_body_with_lf:1; @@ -125,9 +126,9 @@ cmp_uint) != NULL; } -static void add_eol(struct header_filter_istream *mstream) +static void add_eol(struct header_filter_istream *mstream, bool orig_crlf) { - if (mstream->crlf) + if (mstream->crlf || (orig_crlf && mstream->crlf_preserve)) buffer_append(mstream->hdr_buf, "\r\n", 2); else buffer_append_c(mstream->hdr_buf, '\n'); @@ -197,7 +198,7 @@ continue; } - add_eol(mstream); + add_eol(mstream, hdr->crlf_newline); continue; } @@ -239,7 +240,7 @@ buffer_append(mstream->hdr_buf, hdr->value, hdr->value_len); if (!hdr->no_newline) - add_eol(mstream); + add_eol(mstream, hdr->crlf_newline); if (mstream->skip_count >= mstream->hdr_buf->used) { /* we need more */ @@ -266,7 +267,7 @@ } if (!mstream->seen_eoh && mstream->add_missing_eoh) { mstream->seen_eoh = TRUE; - add_eol(mstream); + add_eol(mstream, FALSE); } } @@ -554,7 +555,12 @@ mstream->callback = callback; mstream->context = context; mstream->exclude = (flags & HEADER_FILTER_EXCLUDE) != 0; - mstream->crlf = (flags & HEADER_FILTER_NO_CR) == 0; + if ((flags & HEADER_FILTER_CRLF_PRESERVE) != 0) + mstream->crlf_preserve = TRUE; + else if ((flags & HEADER_FILTER_NO_CR) != 0) + mstream->crlf = FALSE; + else + mstream->crlf = TRUE; mstream->hide_body = (flags & HEADER_FILTER_HIDE_BODY) != 0; mstream->add_missing_eoh = (flags & HEADER_FILTER_ADD_MISSING_EOH) != 0; mstream->end_body_with_lf =
--- a/src/lib-mail/istream-header-filter.h Thu Mar 12 17:41:09 2015 +0200 +++ b/src/lib-mail/istream-header-filter.h Thu Mar 12 19:39:03 2015 +0200 @@ -16,7 +16,9 @@ /* If the empty "end of headers" line doesn't exist, add it. */ HEADER_FILTER_ADD_MISSING_EOH = 0x10, /* If body doesn't end with [CR]LF, add it/them. */ - HEADER_FILTER_END_BODY_WITH_LF = 0x20 + HEADER_FILTER_END_BODY_WITH_LF = 0x20, + /* Preserve the original LF or CRLF. */ + HEADER_FILTER_CRLF_PRESERVE = 0x40 }; struct message_header_line;