Mercurial > dovecot > core-2.2
diff src/lib-mail/message-decoder.c @ 20891:d2872ec409ec
global: Handle broken Content-Type headers consistently.
1) Only the first Content-Type header is used. (Simpler than using the last.)
2) Invalid Content-Types are parsed as far as we can. This is mainly to make
sure they aren't treated as missing Content-Types, which could cause them to
become text/plain.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 10 Oct 2016 20:38:31 +0300 |
parents | 0f22db71df7a |
children | 5ab8dc1a4a6f |
line wrap: on
line diff
--- a/src/lib-mail/message-decoder.c Mon Oct 10 20:24:41 2016 +0300 +++ b/src/lib-mail/message-decoder.c Mon Oct 10 20:38:31 2016 +0300 @@ -127,6 +127,7 @@ struct rfc822_parser_context parser; const char *const *results; string_t *str; + int ret; if (ctx->content_type != NULL) return; @@ -134,9 +135,10 @@ rfc822_parser_init(&parser, hdr->full_value, hdr->full_value_len, NULL); rfc822_skip_lwsp(&parser); str = t_str_new(64); - if (rfc822_parse_content_type(&parser, str) < 0) + ret = rfc822_parse_content_type(&parser, str); + ctx->content_type = i_strdup(str_c(str)); + if (ret < 0) return; - ctx->content_type = i_strdup(str_c(str)); rfc2231_parse(&parser, &results); for (; *results != NULL; results += 2) {