Skip to content

Commit

Permalink
lib-mail: Add MESSAGE_HEADER_REPLACE_NULS_WITH_0x80 flag
Browse files Browse the repository at this point in the history
The flag signals that input stream for message_parse_header() should replace
0x0 symbols with 0x80.
  • Loading branch information
Sergey-Kitov authored and sirainen committed Aug 30, 2018
1 parent 4b6bf52 commit ee1a1f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/lib-mail/message-header-parser.c
Expand Up @@ -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"
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/lib-mail/message-header-parser.h
Expand Up @@ -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 {
Expand Down

0 comments on commit ee1a1f5

Please sign in to comment.