From 6045b2873a1c212aa51b0250b1f5193a28d853f5 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 17 Jul 2024 12:07:38 +0100 Subject: [PATCH] [Minor] Simplify condition and add them merely when mime utf is enabled --- rules/regexp/headers.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/rules/regexp/headers.lua b/rules/regexp/headers.lua index c796f0c81a..daa1e378d2 100644 --- a/rules/regexp/headers.lua +++ b/rules/regexp/headers.lua @@ -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) reconf['R_NO_SPACE_IN_FROM'] = { re = 'From=/\\S<[-\\w\\.]+\\@[-\\w\\.]+>/X', -- 2.47.3