Mercurial > dovecot > core-2.2
changeset 19544:7342f778f152
lib-mail: message-parser was counting body_size wrong for truncated MIME headers after 7d800c55
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Fri, 08 Jan 2016 13:24:32 +0200 |
parents | de4a1694f66c |
children | db146dda35bc |
files | src/lib-mail/message-parser.c src/lib-mail/test-message-parser.c |
diffstat | 2 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-mail/message-parser.c Thu Jan 07 22:14:59 2016 +0200 +++ b/src/lib-mail/message-parser.c Fri Jan 08 13:24:32 2016 +0200 @@ -541,13 +541,16 @@ [CR]LF belongs to the MIME boundary though. */ if (ctx->prev_hdr_newline_size > 0) { i_assert(ctx->part->header_size.lines > 0); + /* remove the newline size from the MIME header */ ctx->part->header_size.lines--; ctx->part->header_size.physical_size -= ctx->prev_hdr_newline_size; - ctx->part->header_size.virtual_size -= + ctx->part->header_size.virtual_size -= 2; + /* add the newline size to the parent's body */ + ctx->part->parent->body_size.lines++; + ctx->part->parent->body_size.physical_size += ctx->prev_hdr_newline_size; - if (ctx->prev_hdr_newline_size == 1) - ctx->part->header_size.virtual_size--; + ctx->part->parent->body_size.virtual_size += 2; } hdr = NULL; }
--- a/src/lib-mail/test-message-parser.c Thu Jan 07 22:14:59 2016 +0200 +++ b/src/lib-mail/test-message-parser.c Fri Jan 08 13:24:32 2016 +0200 @@ -158,6 +158,9 @@ test_assert(message_parser_deinit(&parser, &parts) == 0); test_assert((parts->flags & MESSAGE_PART_FLAG_MULTIPART) != 0); + test_assert(parts->body_size.lines == 8); + test_assert(parts->body_size.physical_size == 112); + test_assert(parts->body_size.virtual_size == 112+7); test_assert(parts->children->header_size.physical_size == 0); test_assert(parts->children->body_size.physical_size == 0); test_assert(parts->children->body_size.lines == 0);