From 8c47bdc7650eb073484f36e55850b42ae035c99d Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Wed, 6 Jul 2016 09:57:47 +0300 Subject: [PATCH] [Minor] Do not treat numbers as extensions in archived file names Do not insert 'MIME_DOUBLE_BAD_EXTENSION' sybmol if next-to-last extension is a number. --- src/plugins/lua/mime_types.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua index 880a17223..8859eadbc 100644 --- a/src/plugins/lua/mime_types.lua +++ b/src/plugins/lua/mime_types.lua @@ -82,7 +82,8 @@ local function check_mime_type(task) if ext then local badness_mult = settings['bad_extensions'][ext] if badness_mult then - if #parts > 2 then + -- Check if next-to-last extension is not a number + if #parts > 2 and not string.match(parts[#parts - 1], '^%d+$') then -- Double extension + bad extension == VERY bad task:insert_result(settings['symbol_double_extension'], badness_mult, { parts[#parts - 1], @@ -98,7 +99,8 @@ local function check_mime_type(task) if is_archive then badness_mult = settings['bad_archive_extensions'][ext] if badness_mult then - if #parts > 2 then + -- Check if next-to-last extension is not a number + if #parts > 2 and not string.match(parts[#parts - 1], '^%d+$') then -- We need to ensure that it is an extension, so we check for its length if #parts[#parts - 1] <= 4 then -- Double extension + bad extension == VERY bad -- 2.39.5