]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: Add MESSAGE_HEADER_REPLACE_NULS_WITH_0x80 flag
authorSergey Kitov <sergey.kitov@open-xchange.com>
Wed, 11 Apr 2018 11:41:45 +0000 (14:41 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 30 Aug 2018 08:13:29 +0000 (11:13 +0300)
The flag signals that input stream for message_parse_header() should replace
0x0 symbols with 0x80.

src/lib-mail/message-header-parser.c
src/lib-mail/message-header-parser.h

index 3db3e4ab97214cfd2ff3776b0d76861dae8f25bd..97d42052419209d06e82f2a386c66c2482c5acc7 100644 (file)
@@ -3,6 +3,7 @@
 #include "lib.h"
 #include "buffer.h"
 #include "istream.h"
+#include "istream-nonuls.h"
 #include "str.h"
 #include "message-size.h"
 #include "message-header-parser.h"
@@ -28,12 +29,16 @@ message_parse_header_init(struct istream *input, struct message_size *hdr_size,
        struct message_header_parser_ctx *ctx;
 
        ctx = i_new(struct message_header_parser_ctx, 1);
-       ctx->input = input;
+       if ((flags & MESSAGE_HEADER_REPLACE_NULS_WITH_0x80) != 0)
+               ctx->input = i_stream_create_nonuls(input, 0x80);
+       else {
+               ctx->input = input;
+               i_stream_ref(input);
+       }
        ctx->hdr_size = hdr_size;
        ctx->name = str_new(default_pool, 128);
        ctx->flags = flags;
        ctx->value_buf = buffer_create_dynamic(default_pool, 4096);
-       i_stream_ref(input);
 
        if (hdr_size != NULL)
                i_zero(hdr_size);
index d6863524aabf2279adc8026612754ef30d8808b0..38594bd18cb7d1720bd6851394d346e1165accf3 100644 (file)
@@ -13,7 +13,9 @@ enum message_header_parser_flags {
        /* Don't add CRs to full_value even if input had them */
        MESSAGE_HEADER_PARSER_FLAG_DROP_CR              = 0x02,
        /* Convert [CR+]LF+LWSP to a space character in full_value */
-       MESSAGE_HEADER_PARSER_FLAG_CLEAN_ONELINE        = 0x04
+       MESSAGE_HEADER_PARSER_FLAG_CLEAN_ONELINE        = 0x04,
+       /* Replace 0x0 symbols with 0x80 */
+       MESSAGE_HEADER_REPLACE_NULS_WITH_0x80           = 0x08,
 };
 
 struct message_header_line {