From 7d14e4af43ee1435b47a5d38b699b24bf598d4bf Mon Sep 17 00:00:00 2001 From: Dmitriy Alekseev <1865999+dragoangel@users.noreply.github.com> Date: Thu, 11 Apr 2024 19:17:08 +0300 Subject: [PATCH] [Enhancement] Exclude false positives of MIME_DOUBLE_BAD_EXTENSION If we detected extension of the file and this extension is equal to the real extension then we should not pass second extension to check function as it will trigger false positive for MIME_DOUBLE_BAD_EXTENSION. --- src/plugins/lua/mime_types.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua index 167ed38e2..71b6481d8 100644 --- a/src/plugins/lua/mime_types.lua +++ b/src/plugins/lua/mime_types.lua @@ -397,7 +397,12 @@ local function check_mime_type(task) if ext2 then local score1 = check_tables(ext) local score2 = check_tables(ext2) - check_extension(score1, score2) + -- Check if detected extension match real extension + if detected_ext and detected_ext == ext then + check_extension(score1, nil) + else + check_extension(score1, score2) + end -- Check for archive cloaking like .zip.gz if settings['archive_extensions'][ext2] -- Exclude multipart archive extensions, e.g. .zip.001 -- 2.39.5