mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Fix: Correct unit comparison bug in webportal document download (#36256)
The file size check was comparing bytes (from dol_filesize) directly with kilobytes (from MAIN_SECURITY_MAXFILESIZE_DOWNLOADED config), causing false positives that blocked downloads of small files. Example: A 94 KB file (96678 bytes) was rejected because 96678 > 20480, even though the limit was actually 20480 KB (20 MB). Changes: - Convert KB limit to bytes before comparison: $fileSizeMax * 1024 - Improve error message to display file size in KB for consistency - Add detailed logging with both bytes and KB values Fixes: Files under the configured limit are now correctly allowed to download
This commit is contained in:
committed by
GitHub
parent
545a0f5532
commit
f837fb4fa8
@@ -214,9 +214,11 @@ class DocumentController extends Controller
|
||||
|
||||
$fileSize = dol_filesize($fullpath_original_file);
|
||||
$fileSizeMax = getDolGlobalInt('MAIN_SECURITY_MAXFILESIZE_DOWNLOADED');
|
||||
if ($fileSizeMax && $fileSize > $fileSizeMax) {
|
||||
dol_syslog('ErrorFileSizeTooLarge: ' . $fileSize);
|
||||
print 'ErrorFileSizeTooLarge: ' . $fileSize . ' (max ' . $fileSizeMax . ' Kb)';
|
||||
if ($fileSizeMax && $fileSize > ($fileSizeMax * 1024)) {
|
||||
// FIX: Convert limit from Ko to bytes for proper comparison
|
||||
$fileSizeKb = round($fileSize / 1024, 2);
|
||||
dol_syslog('ErrorFileSizeTooLarge: ' . $fileSize . ' bytes (' . $fileSizeKb . ' Kb) - max allowed: ' . $fileSizeMax . ' Kb');
|
||||
print 'ErrorFileSizeTooLarge: ' . $fileSizeKb . ' Kb (max ' . $fileSizeMax . ' Kb)';
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user