From eb3fca0e205a2410aa9a2fdf6874e0a84fc015b2 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 20 Jun 2004 09:14:00 +0300 Subject: [PATCH] Make sure headers end with LF --HG-- branch : HEAD --- src/lib-storage/mail-save.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib-storage/mail-save.c b/src/lib-storage/mail-save.c index 69e85f65a6..ab09caf597 100644 --- a/src/lib-storage/mail-save.c +++ b/src/lib-storage/mail-save.c @@ -94,7 +94,7 @@ static int save_headers(struct istream *input, struct ostream *output, { struct message_header_parser_ctx *hdr_ctx; struct message_header_line *hdr; - int ret = 0; + int last_newline = TRUE, ret = 0; hdr_ctx = message_parse_header_init(input, NULL, FALSE); while ((hdr = message_parse_header_next(hdr_ctx)) != NULL) { @@ -114,10 +114,17 @@ static int save_headers(struct istream *input, struct ostream *output, (void)o_stream_send(output, hdr->value, hdr->value_len); if (!hdr->no_newline) write_func(output, "\n", 1); + last_newline = !hdr->no_newline; + } else { + last_newline = TRUE; } } if (ret >= 0) { + if (!last_newline) { + /* don't allow headers that don't terminate with \n */ + write_func(output, "\n", 1); + } if (header_callback(NULL, write_func, context) < 0) ret = -1; -- 2.47.3