From: Vsevolod Stakhov Date: Tue, 13 Dec 2016 10:19:48 +0000 (+0000) Subject: [Minor] Add more flags to content type X-Git-Tag: 1.5.0~604 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d6c093493b58ff7ea34b0351d79a8d78af7d678f;p=thirdparty%2Frspamd.git [Minor] Add more flags to content type --- diff --git a/src/libmime/content_type.c b/src/libmime/content_type.c index 0e2a89a77e..4a281eef5e 100644 --- a/src/libmime/content_type.c +++ b/src/libmime/content_type.c @@ -90,12 +90,6 @@ rspamd_content_type_parse (const gchar *in, (rspamd_mempool_destruct_t)g_hash_table_unref, res->attrs); } - srch.begin = "multipart"; - srch.len = 9; - - if (rspamd_ftok_cmp (&res->type, &srch) == 0) { - res->flags |= RSPAMD_CONTENT_TYPE_MULTIPART; - } /* Now do some hacks to work with broken content types */ if (res->subtype.len == 0) { @@ -142,6 +136,29 @@ rspamd_content_type_parse (const gchar *in, res->subtype.len = 11; } } + + srch.begin = "multipart"; + srch.len = 9; + + if (rspamd_ftok_cmp (&res->type, &srch) == 0) { + res->flags |= RSPAMD_CONTENT_TYPE_MULTIPART; + } + else { + srch.begin = "text"; + srch.len = 4; + + if (rspamd_ftok_cmp (&res->type, &srch) == 0) { + res->flags |= RSPAMD_CONTENT_TYPE_TEXT; + } + else { + srch.begin = "message"; + srch.len = 7; + + if (rspamd_ftok_cmp (&res->type, &srch) == 0) { + res->flags |= RSPAMD_CONTENT_TYPE_MESSAGE; + } + } + } } else { msg_warn_pool ("cannot parse content type: %*s", (gint)len, val.lc_data); diff --git a/src/libmime/content_type.h b/src/libmime/content_type.h index f417ab8d6b..dc5355918d 100644 --- a/src/libmime/content_type.h +++ b/src/libmime/content_type.h @@ -24,6 +24,8 @@ enum rspamd_content_type_flags { RSPAMD_CONTENT_TYPE_VALID = 0, RSPAMD_CONTENT_TYPE_BROKEN = 1 << 0, RSPAMD_CONTENT_TYPE_MULTIPART = 1 << 1, + RSPAMD_CONTENT_TYPE_TEXT = 1 << 2, + RSPAMD_CONTENT_TYPE_MESSAGE = 1 << 3, }; struct rspamd_content_type_param {