aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-27 12:25:16 +0000
committerGitHub <noreply@github.com>2018-02-27 12:25:16 +0000
commit2452fe09ea8579da8ab5c842ff050a30c4d94062 (patch)
tree64b1ae4c289ebac2498240659febebff1da7b9b9
parent75e699c0b2fe1e1eabe8c4aa90957d8cb1ed1ae0 (diff)
parent01390ee897e7e3f186f3abf8c009d07dc1247661 (diff)
downloadrspamd-2452fe09ea8579da8ab5c842ff050a30c4d94062.tar.gz
rspamd-2452fe09ea8579da8ab5c842ff050a30c4d94062.zip
Merge pull request #2036 from moisseev/mime-types
[Feature] Allow multiple CTs in full extensions map
-rw-r--r--src/plugins/lua/mime_types.lua30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua
index eac91adc6..27dbfc89c 100644
--- a/src/plugins/lua/mime_types.lua
+++ b/src/plugins/lua/mime_types.lua
@@ -781,7 +781,7 @@ local full_extensions_map = {
{"xltm", "application/vnd.ms-excel.template.macroEnabled.12"},
{"xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"},
{"xlw", "application/vnd.ms-excel"},
- {"xml", "text/xml"},
+ {"xml", {"application/xml", "text/xml"}},
{"xmp", "application/octet-stream" },
{"xmta", "application/xml"},
{"xof", "x-world/x-vrml"},
@@ -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