]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add more flags to content type
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 13 Dec 2016 10:19:48 +0000 (10:19 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 13 Dec 2016 10:19:48 +0000 (10:19 +0000)
src/libmime/content_type.c
src/libmime/content_type.h

index 0e2a89a77e729df92ae05dc4312dbab5aed57d8b..4a281eef5e4e5b3f294d9d76a1759f04461e743f 100644 (file)
@@ -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);
index f417ab8d6b57b546ed844868727870d82ac6d7fa..dc5355918df67985200cebdd44c83a18d52aa9e6 100644 (file)
@@ -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 {