diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-02-27 10:27:24 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-02-27 10:27:24 +0300 |
commit | 9a0ff1213ebf6d9c45f8305c01969110fe3cd7c1 (patch) | |
tree | e6c3bd4a82b17201131851b191e14f2a7d56fb0f /src | |
parent | eb5c6dcd495a2edff6f0da4baf40eff59c2f460d (diff) | |
download | rspamd-9a0ff1213ebf6d9c45f8305c01969110fe3cd7c1.tar.gz rspamd-9a0ff1213ebf6d9c45f8305c01969110fe3cd7c1.zip |
[Feature] Allow multiple CTs in full extensions map
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/lua/mime_types.lua | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua index eac91adc6..5eae115e0 100644 --- a/src/plugins/lua/mime_types.lua +++ b/src/plugins/lua/mime_types.lua @@ -974,34 +974,34 @@ if opts then settings[k] = v end - -- Transform extension_map - for k,v in pairs(settings.extension_map) do - if type(v) == 'table' then + local function change_extension_map_entry(ext, ct, mult) + if type(ct) == 'table' then local tbl = {} - for _,elt in ipairs(v) do + for _,elt in ipairs(ct) do table.insert(tbl, { ct = elt, - mult = 1.0, + mult = mult, }) end - settings.extension_map[k] = tbl + settings.extension_map[ext] = tbl else - settings.extension_map[k] = { [1] = { - ct = v, - mult = 1.0 + settings.extension_map[ext] = { [1] = { + ct = ct, + mult = mult } } end end + -- Transform extension_map + for ext,ct in pairs(settings.extension_map) do + change_extension_map_entry(ext, ct, 1.0) + end + -- Add all extensions for _,pair in ipairs(full_extensions_map) do local ext, ct = pair[1], pair[2] - if not settings.extension_map[ext] then - settings.extension_map[ext] = { [1] = { - ct = ct, - mult = settings.other_extensions_mult - } } + change_extension_map_entry(ext, ct, settings.other_extensions_mult) end end |