]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Simplify condition and add them merely when mime utf is enabled
authorVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 17 Jul 2024 11:07:38 +0000 (12:07 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 17 Jul 2024 11:07:38 +0000 (12:07 +0100)
rules/regexp/headers.lua

index c796f0c81ad5fc9e5bb9f44bc698af34353e4a14..daa1e378d2c9d97e7fdb73fb9032ca920e385416 100644 (file)
@@ -31,9 +31,6 @@ reconf['SUBJECT_NEEDS_ENCODING'] = {
   score = 1.0,
   mime_only = true,
   description = 'Subject needs encoding',
-  condition = function()
-    return not rspamd_config:is_mime_utf()
-  end,
   group = 'headers'
 }
 
@@ -45,9 +42,6 @@ reconf['FROM_NEEDS_ENCODING'] = {
   score = 1.0,
   mime_only = true,
   description = 'From header needs encoding',
-  condition = function()
-    return not rspamd_config:is_mime_utf()
-  end,
   group = 'headers'
 }
 
@@ -59,12 +53,22 @@ reconf['TO_NEEDS_ENCODING'] = {
   score = 1.0,
   mime_only = true,
   description = 'To header needs encoding',
-  condition = function()
-    return not rspamd_config:is_mime_utf()
-  end,
   group = 'headers',
 }
 
+if rspamd_config:is_mime_utf() then
+  -- Disable some of the rules preserving the underlying logic
+  reconf['FROM_NEEDS_ENCODING'].condition = function()
+    return false
+  end
+  reconf['TO_NEEDS_ENCODING'].condition = function()
+    return false
+  end
+  reconf['SUBJECT_NEEDS_ENCODING'].condition = function()
+    return false
+  end
+end
+
 -- Detects that there is no space in From header (e.g. Some Name<some@host>)
 reconf['R_NO_SPACE_IN_FROM'] = {
   re = 'From=/\\S<[-\\w\\.]+\\@[-\\w\\.]+>/X',