From e5bb0183d3480d9ce6840ad203da5c25fc0525b7 Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Wed, 6 Dec 2017 23:23:21 +0300 Subject: [Fix] Once more (#1879) fix bad extension check when next-to-last extension is a number or date, e.g. 06.12.2017.scr --- src/plugins/lua/mime_types.lua | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src') 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 -- cgit v1.2.3