aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua
diff options
context:
space:
mode:
authorAlexander Moisseev <moiseev@mezonplus.ru>2016-03-22 11:50:08 +0300
committerAlexander Moisseev <moiseev@mezonplus.ru>2016-03-22 11:50:08 +0300
commitf05607bf6a96ccb0a7d87d5fc51beaa5e1ce6bb9 (patch)
treeb69adc94ce9e67200f40de6a73fcc9cb57438143 /src/plugins/lua
parent0f821cb3ee78cac17c0bd562a801e954556d6a3e (diff)
downloadrspamd-f05607bf6a96ccb0a7d87d5fc51beaa5e1ce6bb9.tar.gz
rspamd-f05607bf6a96ccb0a7d87d5fc51beaa5e1ce6bb9.zip
[Feature] Add list support to `mime types` module configuration
- this change allows to configure several mime types for an extension like ```txt = [ "message/disposition-notification", "text/plain", "text/rfc822-headers" ];``` - `type` variable replaced with `mtype` as `type` is lua reserved word
Diffstat (limited to 'src/plugins/lua')
-rw-r--r--src/plugins/lua/mime_types.lua25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua
index 1014480a3..2c168393b 100644
--- a/src/plugins/lua/mime_types.lua
+++ b/src/plugins/lua/mime_types.lua
@@ -39,21 +39,36 @@ local function check_mime_type(task)
if parts then
for _,p in ipairs(parts) do
- local type,subtype = p:get_type()
+ local mtype,subtype = p:get_type()
- if not type then
+ if not mtype then
task:insert_result(settings['symbol_unknown'], 1.0, 'missing content type')
else
-- Check for attachment
local filename = p:get_filename()
- local ct = string.format('%s/%s', type, subtype)
+ local ct = string.format('%s/%s', mtype, subtype)
if filename then
local ext = string.match(filename, '%.([^.]+)$')
if ext then
- if settings['extension_map'][ext] then
- if ct ~= settings['extension_map'][ext] then
+ local mt = settings['extension_map'][ext]
+ if mt then
+ local found = nil
+ if (type(mt) == "table") then
+ for _,v in pairs(mt) do
+ if ct == v then
+ found = true
+ break
+ end
+ end
+ else
+ if ct == mt then
+ found = true
+ end
+ end
+
+ if not found then
task:insert_result(settings['symbol_attachment'], 1.0, ext)
end
end