From ed3bee3909beebe001c17710a5208ef8015a1665 Mon Sep 17 00:00:00 2001 From: TehPeGaSuS <25697531+TehPeGaSuS@users.noreply.github.com> Date: Fri, 16 Oct 2026 12:38:32 +0200 Subject: [PATCH] Ignore trailing dots and whitespace when checking file extension --- lib/functions.js.php | 2 +- lib/functions.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/functions.js.php b/lib/functions.js.php index 656108b..9307eda 100644 --- a/lib/functions.js.php +++ b/lib/functions.js.php @@ -356,7 +356,7 @@ function control_selected_file_size(max_size, error_str) // just warns the user before they submit a doomed upload. function control_selected_file_extension(disallowed_extensions, error_str) { - f_name = document.getElementById('file_select').files[0].name; + f_name = document.getElementById('file_select').files[0].name.replace(/[\s.]+$/, ''); f_ext = f_name.includes('.') ? f_name.split('.').pop().toLowerCase() : ''; if (disallowed_extensions.includes(f_ext)) { diff --git a/lib/functions.php b/lib/functions.php index 8bfa61b..6090248 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -241,6 +241,8 @@ function jirafeau_is_extension_allowed($cfg, $filename) return true; } + // trailing dots and whitespace are dropped on storage or by the client OS + $filename = rtrim($filename, " \t\n\r\0\x0B."); $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); $disallowed = array_map('strtolower', $cfg['disallowed_extensions']); -- 2.43.0