From f2d40f82a9fa08c238a2fd37b5a594ca80506b13 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 9 May 2004 20:05:18 +0300 Subject: [PATCH] If value of header contains only LWSP, return all LWSP instead of returning just empty value. --HG-- branch : HEAD --- src/lib-mail/message-parser.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/lib-mail/message-parser.c b/src/lib-mail/message-parser.c index 67acf0f51f..9ea0d1273b 100644 --- a/src/lib-mail/message-parser.c +++ b/src/lib-mail/message-parser.c @@ -842,15 +842,27 @@ message_parse_header_next(struct message_header_parser_ctx *ctx) line->name_len = str_len(ctx->name); } else { /* get value. skip all LWSP after ':'. Note that RFC2822 - doesn't say we should, but history behind it.. */ + doesn't say we should, but history behind it.. + + Exception to this is if the value consists only of LWSP, + then skip only the one LWSP after ':'. */ line->value = msg + colon_pos+1; line->value_len = size - colon_pos - 1; - while (line->value_len > 0 && - IS_LWSP(line->value[0])) { + while (line->value_len > 0 && IS_LWSP(line->value[0])) { line->value++; line->value_len--; } + if (line->value_len == 0) { + /* everything was LWSP */ + line->value = msg + colon_pos+1; + line->value_len = size - colon_pos - 1; + if (line->value_len > 0 && IS_LWSP(line->value[0])) { + line->value++; + line->value_len--; + } + } + /* get name, skip LWSP before ':' */ while (colon_pos > 0 && IS_LWSP(msg[colon_pos-1])) colon_pos--; -- 2.47.3