Browse Source

[Fix] Fix inconsistent nesting in mime parts

We should do like MUAs do: imlicitly close incomplete mime parts
and treat them as ususal. It is weird and utterly stupid but that's
what MUA do.

Issue: #4740
Closes: #4740
pull/4882/head
Vsevolod Stakhov 1 month ago
parent
commit
10577f1f79
No account linked to committer's email address
1 changed files with 8 additions and 1 deletions
  1. 8
    1
      src/libmime/mime_parser.c

+ 8
- 1
src/libmime/mime_parser.c View File

goffset last_offset; goffset last_offset;
unsigned int i, sel = 0; unsigned int i, sel = 0;
enum rspamd_mime_parse_error ret; enum rspamd_mime_parse_error ret;
bool enforce_closing = false;


last_offset = (multipart->raw_data.begin - st->start) + last_offset = (multipart->raw_data.begin - st->start) +
multipart->raw_data.len; multipart->raw_data.len;
cur = &g_array_index(st->boundaries, struct rspamd_mime_boundary, i); cur = &g_array_index(st->boundaries, struct rspamd_mime_boundary, i);


if (cur->boundary > last_offset) { if (cur->boundary > last_offset) {
/*
* We have reached the end of the part, so we have to close it implicitly
* like MUA do
*/
task->flags |= RSPAMD_TASK_FLAG_BROKEN_HEADERS;
enforce_closing = true;
break; break;
} }


} }
} }


if (i == st->boundaries->len && cb->cur_boundary) {
if (enforce_closing || (i == st->boundaries->len && cb->cur_boundary)) {
/* Process the last part */ /* Process the last part */
struct rspamd_mime_boundary fb; struct rspamd_mime_boundary fb;



Loading…
Cancel
Save