diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2017-12-06 23:23:21 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2017-12-06 23:23:21 +0300 |
commit | e5bb0183d3480d9ce6840ad203da5c25fc0525b7 (patch) | |
tree | 33e8e797feb5e101371149623a847a6712854790 | |
parent | c0b636ed17c1b96d7ae5bb4fc7ae2a98bd75196e (diff) | |
download | rspamd-e5bb0183d3480d9ce6840ad203da5c25fc0525b7.tar.gz rspamd-e5bb0183d3480d9ce6840ad203da5c25fc0525b7.zip |
[Fix] Once more (#1879) fix bad extension check
when next-to-last extension is a number or date, e.g. 06.12.2017.scr
-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 |