diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-12-18 15:51:27 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-12-18 15:51:27 +0000 |
commit | fe9e2384c6099cb57408f8d74b52f839d9d6326e (patch) | |
tree | 980b6e13b2ff080958ce57b1aca3551b1fc409a5 /lualib | |
parent | 9eaf83a15b4ddaef0a2b107cdf8876695d8b57d8 (diff) | |
download | rspamd-fe9e2384c6099cb57408f8d74b52f839d9d6326e.tar.gz rspamd-fe9e2384c6099cb57408f8d74b52f839d9d6326e.zip |
[Feature] Rspamadm: Allow to rewrite headers in messages
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/rspamadm/mime.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lualib/rspamadm/mime.lua b/lualib/rspamadm/mime.lua index 423a6910a..96bdfd72c 100644 --- a/lualib/rspamadm/mime.lua +++ b/lualib/rspamadm/mime.lua @@ -142,6 +142,10 @@ modify:option "-r --remove-header" :description "Removes specific header (all occurrences)" :argname "<header>" :count "*" +modify:option "-R --rewrite-header" + :description "Rewrites specific header, uses Lua string.format pattern" + :argname "<header=pattern>" + :count "*" modify:option "-t --text-footer" :description "Adds footer to text/plain parts from a specific file" :argname "<file>" @@ -670,6 +674,20 @@ local function modify_handler(opts) end end + for _,h in ipairs(opts['rewrite_header']) do + local hname,hpattern = h:match('^([^=]+)=(.+)$') + if hname == name then + local new_value = string.format(hpattern, hdr.decoded) + new_value = string.format('%s:%s%s%s', + name, hdr.separator, + rspamd_util.fold_header(name, + rspamd_util.mime_header_encode(new_value), + task:get_newlines_type()), newline_s) + io.write(new_value) + return + end + end + if need_rewrite_ct then if name:lower() == 'content-type' then local nct = string.format('%s: %s/%s; charset=utf-8%s', |