From: Vsevolod Stakhov Date: Wed, 17 Jul 2024 11:07:38 +0000 (+0100) Subject: [Minor] Simplify condition and add them merely when mime utf is enabled X-Git-Tag: 3.10.0~4^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6045b2873a1c212aa51b0250b1f5193a28d853f5;p=thirdparty%2Frspamd.git [Minor] Simplify condition and add them merely when mime utf is enabled --- 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',