]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Disable text detection heuristics for encrypted parts
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 28 Apr 2020 14:38:47 +0000 (15:38 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 28 Apr 2020 14:38:47 +0000 (15:38 +0100)
Issue: #3349

lualib/lua_magic/heuristics.lua
src/libmime/content_type.c
src/libmime/content_type.h

index d9d4081702e1d307a5705dda1b73ebf22fa25f55..8aeafae905f4f883dd389ba09358117ff7c47e3e 100644 (file)
@@ -377,6 +377,19 @@ exports.text_part_heuristic = function(part, log_obj)
     return true
   end
 
+  local parent = part:get_parent()
+
+  if parent then
+    local parent_type,parent_subtype = parent:get_type()
+
+    if parent_type == 'multipart' and parent_subtype == 'encrypted' then
+      -- Skip text heuristics for encrypted parts
+      lua_util.debugm(N, log_obj, "text part check: parent is encrypted, not a text part")
+
+      return false
+    end
+  end
+
   local content = part:get_content()
   local clen = #content
   local is_text
index 3de9bdb1253b11cfba54b81204e7b8e57f8ce6c2..1540e6b23891277a9058c6b58d005b96a410afa2 100644 (file)
@@ -709,6 +709,11 @@ rspamd_content_type_parse (const gchar *in,
 
                if (rspamd_ftok_casecmp (&res->type, &srch) == 0) {
                        res->flags |= RSPAMD_CONTENT_TYPE_MULTIPART;
+
+                       RSPAMD_FTOK_ASSIGN (&srch, "encrypted");
+                       if (rspamd_ftok_casecmp (&res->subtype, &srch) == 0) {
+                               res->flags |= RSPAMD_CONTENT_TYPE_ENCRYPTED;
+                       }
                }
                else {
                        RSPAMD_FTOK_ASSIGN (&srch, "text");
index 49bba4269b60c12154f2f69089b6d96d967b3387..3991e6785bfb4925423465c85c22187d0983954b 100644 (file)
@@ -32,6 +32,7 @@ enum rspamd_content_type_flags {
        RSPAMD_CONTENT_TYPE_MESSAGE = 1 << 3,
        RSPAMD_CONTENT_TYPE_DSN = 1 << 4,
        RSPAMD_CONTENT_TYPE_MISSING = 1 << 5,
+       RSPAMD_CONTENT_TYPE_ENCRYPTED = 1 << 1,
 };
 
 enum rspamd_content_param_flags {