Mercurial > dovecot > core-2.2
changeset 20889:f8ba998a6b7c
lib-imap: Don't write a broken Content-Type as text/plain to BODYSTRUCTURE
Mainly because it doesn't match with MESSAGE_PART_FLAG_TEXT in message_part.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 10 Oct 2016 20:23:47 +0300 |
parents | 79bc30406f1e |
children | d946c76fb3d4 |
files | src/lib-imap/imap-bodystructure.c |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-imap/imap-bodystructure.c Sat Oct 15 23:04:35 2016 +0300 +++ b/src/lib-imap/imap-bodystructure.c Mon Oct 10 20:23:47 2016 +0300 @@ -36,13 +36,13 @@ string_t *str; unsigned int i; bool charset_found = FALSE; + int ret; rfc822_parser_init(&parser, hdr->full_value, hdr->full_value_len, NULL); rfc822_skip_lwsp(&parser); str = t_str_new(256); - if (rfc822_parse_content_type(&parser, str) < 0) - return; + ret = rfc822_parse_content_type(&parser, str); /* Save content type and subtype */ value = str_c(str); @@ -56,6 +56,16 @@ str_truncate(str, i); data->content_type = imap_get_string(data->pool, str_c(str)); + if (ret < 0) { + /* Content-Type is broken, but we wanted to get it as well as + we could. Don't try to read the parameters anymore though. + + We don't completely ignore a broken Content-Type, because + then it would be written as text/plain. This would cause a + mismatch with the message_part's MESSAGE_PART_FLAG_TEXT. */ + return; + } + /* parse parameters and save them */ str_truncate(str, 0); rfc2231_parse(&parser, &results);