diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-12-02 13:39:22 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-12-02 13:39:22 +0000 |
commit | 11e153c0147690a9649966263b393ec1ad750c1b (patch) | |
tree | e2d550adff3c6c8ef70e3b08893df5061b7d9646 | |
parent | f0e20efae58e69ed49980cd186b0623ee3615ee4 (diff) | |
download | rspamd-11e153c0147690a9649966263b393ec1ad750c1b.tar.gz rspamd-11e153c0147690a9649966263b393ec1ad750c1b.zip |
[Minor] Some more adjustments
-rw-r--r-- | lualib/lua_mime.lua | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lualib/lua_mime.lua b/lualib/lua_mime.lua index 2cbdda804..75e5d11f8 100644 --- a/lualib/lua_mime.lua +++ b/lualib/lua_mime.lua @@ -966,6 +966,9 @@ end -- @return {table} modified message state similar to other modification functions --]] exports.anonymize_message = function(task, settings) + local rspamd_re = require "rspamd_regexp" + -- We exclude words with digits, currency symbols and so on + local exclude_words_re = rspamd_re.create_cached([[/^(?:\d+|\d+\D{1,3}|\p{Sc}.*|(\+?\d{1,3}[\s\-]?)?)$/u]]) local newline_s = newline(task) local state = { newline_s = newline_s @@ -1039,6 +1042,11 @@ exports.anonymize_message = function(task, settings) if sel_part then text_content = sel_part:get_words('norm') + for i, w in ipairs(text_content) do + if exclude_words_re:match(w) then + text_content[i] = string.rep('x', #w) + end + end end -- Process URLs @@ -1080,10 +1088,12 @@ exports.anonymize_message = function(task, settings) true } for _, hdr in ipairs(modified_headers) do - out[#out + 1] = { - string.format('%s: %s', hdr.name, hdr.value), - true - } + if hdr.name ~= 'Content-Type' then + out[#out + 1] = { + string.format('%s: %s', hdr.name, hdr.value), + true + } + end end out[#out + 1] = { '', true } @@ -1099,7 +1109,7 @@ exports.anonymize_message = function(task, settings) out[#out + 1] = { '', true } out[#out + 1] = { rspamd_util.encode_qp(new_text, 76, task:get_newlines_type()), - false + true } -- Close boundaries |