if (ctx->total_parts_count >= ctx->max_total_mime_parts) {
/* can't add any more MIME parts. just stop trying to find
more boundaries. */
+ ctx->part->flags |= MESSAGE_PART_FLAG_OVERFLOW;
return -1;
}
parse_next_body_multipart_init(ctx);
ctx->multipart = TRUE;
} else {
+ part->flags |= MESSAGE_PART_FLAG_OVERFLOW;
part->flags &= ENUM_NEGATE(MESSAGE_PART_FLAG_MULTIPART);
}
}
i_assert(ctx->last_boundary == NULL);
ctx->multipart = FALSE;
ctx->parse_next_block = parse_next_body_to_boundary;
- } else if ((part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) != 0 &&
- !parse_too_many_nested_mime_parts(ctx) &&
+ } else if ((part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) == 0) {
+ /* Not message/rfc822 */
+ if (ctx->boundaries != NULL)
+ ctx->parse_next_block = parse_next_body_to_boundary;
+ else
+ ctx->parse_next_block = parse_next_body_to_eof;
+ } else if (!parse_too_many_nested_mime_parts(ctx) &&
ctx->total_parts_count < ctx->max_total_mime_parts) {
+ /* message/rfc822 - not reached MIME part limits yet */
ctx->parse_next_block = parse_next_body_message_rfc822_init;
} else {
+ /* message/rfc822 - already reached MIME part limits */
+ part->flags |= MESSAGE_PART_FLAG_OVERFLOW;
part->flags &= ENUM_NEGATE(MESSAGE_PART_FLAG_MESSAGE_RFC822);
if (ctx->boundaries != NULL)
ctx->parse_next_block = parse_next_body_to_boundary;
MESSAGE_PART_FLAG_HAS_NULS = 0x20,
/* Mime-Version header exists. */
- MESSAGE_PART_FLAG_IS_MIME = 0x40
+ MESSAGE_PART_FLAG_IS_MIME = 0x40,
+ /* Message parsing was aborted because there were too many MIME parts.
+ This MIME part points to a blob which wasn't actually parsed to
+ see if it would contain further MIME parts. */
+ MESSAGE_PART_FLAG_OVERFLOW = 0x80,
};
struct message_part {
part = parts->children;
test_assert(part->children_count == 0);
- test_assert(part->flags == MESSAGE_PART_FLAG_IS_MIME);
+ test_assert(part->flags == (MESSAGE_PART_FLAG_IS_MIME |
+ MESSAGE_PART_FLAG_OVERFLOW));
test_assert(part->header_size.lines == 2);
test_assert(part->header_size.physical_size == 45);
test_assert(part->header_size.virtual_size == 45+2);
part = parts->children;
test_assert(part->children_count == 0);
- test_assert(part->flags == MESSAGE_PART_FLAG_IS_MIME);
+ test_assert(part->flags == (MESSAGE_PART_FLAG_IS_MIME |
+ MESSAGE_PART_FLAG_OVERFLOW));
test_assert(part->header_size.lines == 2);
test_assert(part->header_size.physical_size == 30);
test_assert(part->header_size.virtual_size == 30+2);
part = parts->children->children->next;
test_assert(part->children_count == 0);
- test_assert(part->flags == (MESSAGE_PART_FLAG_TEXT | MESSAGE_PART_FLAG_IS_MIME));
+ test_assert(part->flags == (MESSAGE_PART_FLAG_TEXT |
+ MESSAGE_PART_FLAG_IS_MIME |
+ MESSAGE_PART_FLAG_OVERFLOW));
test_assert(part->header_size.lines == 2);
test_assert(part->header_size.physical_size == 26);
test_assert(part->header_size.virtual_size == 26+2);
part = parts->children->children;
test_assert(part->children_count == 0);
- test_assert(part->flags == MESSAGE_PART_FLAG_IS_MIME);
+ test_assert(part->flags == (MESSAGE_PART_FLAG_IS_MIME |
+ MESSAGE_PART_FLAG_OVERFLOW));
test_assert(part->header_size.lines == 2);
test_assert(part->header_size.physical_size == 30);
test_assert(part->header_size.virtual_size == 30+2);
part = part->children;
test_assert_idx(part->children_count == 0, i);
- test_assert_idx(part->flags == 72, i);
+ test_assert_idx(part->flags == (MESSAGE_PART_FLAG_TEXT |
+ MESSAGE_PART_FLAG_IS_MIME |
+ MESSAGE_PART_FLAG_OVERFLOW), i);
test_assert_idx(part->header_size.lines == 2, i);
test_assert_idx(part->header_size.physical_size == 26, i);
test_assert_idx(part->header_size.virtual_size == 28, i);