diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-12-06 20:37:41 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-06 20:37:41 +0000 |
commit | 902c55e5bec49c134e28ed468ac0fe46ab5dfc35 (patch) | |
tree | 4685f36c7462ecccbc7a535b3baef919e63a07fb /src | |
parent | 352a465639b64e024e54e25b76d59e4e68b798b5 (diff) | |
parent | e5bb0183d3480d9ce6840ad203da5c25fc0525b7 (diff) | |
download | rspamd-902c55e5bec49c134e28ed468ac0fe46ab5dfc35.tar.gz rspamd-902c55e5bec49c134e28ed468ac0fe46ab5dfc35.zip |
Merge pull request #1948 from moisseev/mime_types
[Fix] Once more (#1879) fix bad extension check
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/lua/mime_types.lua | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua index a93b5889c..9dee24c6b 100644 --- a/src/plugins/lua/mime_types.lua +++ b/src/plugins/lua/mime_types.lua @@ -112,23 +112,24 @@ local function check_mime_type(task) if #parts > 2 then -- We need to ensure that it is an extension, so we check for its length -- Check if next-to-last extension is not a number or date - if #ext > 4 or (ext2 and string.match(ext2, '^%d+$')) then return end + if #ext <= 4 and ext2 and not string.match(ext2, '^%d+$') then - -- Use the greatest badness multiplier - if not badness_mult or - (badness_mult2 and badness_mult < badness_mult2) then - badness_mult = badness_mult2 - end + -- Use the greatest badness multiplier + if not badness_mult or + (badness_mult2 and badness_mult < badness_mult2) then + badness_mult = badness_mult2 + end - -- Double extension + bad extension == VERY bad - task:insert_result(settings['symbol_double_extension'], badness_mult, - string.format(".%s.%s", ext2, ext)) - else - if badness_mult then - -- Just bad extension - task:insert_result(settings['symbol_bad_extension'], badness_mult, ext) + -- Double extension + bad extension == VERY bad + task:insert_result(settings['symbol_double_extension'], badness_mult, + string.format(".%s.%s", ext2, ext)) + return end end + if badness_mult then + -- Just bad extension + task:insert_result(settings['symbol_bad_extension'], badness_mult, ext) + end end if ext then |