// 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))
{
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']);