From: Patrick Canterino Date: Fri, 5 Jun 2026 14:02:08 +0000 (+0200) Subject: Merge branch 'fix_legacy_upload' into 'next-release' X-Git-Tag: 4.7.2~9 X-Git-Url: https://git.p6c8.net/jirafeau/pcanterino.git/commitdiff_plain/39ff6f56cbd8157556111441c987f2dd3258090a?hp=1733d88de2fe686cf95ef396eb1566e7db336b0a Merge branch 'fix_legacy_upload' into 'next-release' Fixed file encryption on classic upload See merge request jirafeau/Jirafeau!34 --- diff --git a/lib/config.original.php b/lib/config.original.php index 6b7c342..37c87eb 100644 --- a/lib/config.original.php +++ b/lib/config.original.php @@ -235,6 +235,10 @@ $cfg['installation_done'] = false; */ $cfg['debug'] = false; +/* Enable this debug flag to enforce the classic (synchronous) file upload mechanism. + */ +$cfg['debug_enforce_classic_upload'] = false; + /* Set Jirafeau's maximal upload chunk * When Jirafeau upload a large file, Jirafeau sends several data chunks to fit server's capabilities. * Jirafeau tries to upload each data chunk with the maximal size allowed by PHP (post_max_size and upload_max_filesize). diff --git a/lib/functions.js.php b/lib/functions.js.php index 29d50c1..cafecaf 100644 --- a/lib/functions.js.php +++ b/lib/functions.js.php @@ -430,9 +430,9 @@ function classic_upload (file, time, password, one_time) req.upload.addEventListener ("progress", upload_progress, false); req.addEventListener ("error", XHRErrorHandler, false); req.addEventListener ("abort", XHRErrorHandler, false); - req.onreadystatechange = function () + req.onload = function () { - if (req.readyState == 4 && req.status == 200) + if (req.status === 200) { var res = req.responseText; @@ -479,6 +479,13 @@ function classic_upload (file, time, password, one_time) function check_html5_file_api () { + + // Enforce classic upload is enabled through config! + return false; + return window.File && window.FileReader && window.FileList && window.Blob; } diff --git a/lib/functions.php b/lib/functions.php index 833e21b..948a436 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -464,9 +464,9 @@ function jirafeau_handle_add_file_encryption($crypt_module_enabled, $file_path) error_log("PHP extension sodium not loaded, won't encrypt in Jirafeau"); } if ($crypt_module_enabled == true && extension_loaded('sodium') == true) { - $crypt_key = jirafeau_encrypt_file($file_path, $file_path.'crypt'); + $crypt_key = jirafeau_encrypt_file($file_path, $file_path.'.crypt'); if (strlen($crypt_key) > 0) { - if (rename($file_path.'crypt', $file_path) === true) { + if (rename($file_path.'.crypt', $file_path) === true) { $crypted = true; } } @@ -554,7 +554,7 @@ function jirafeau_add_file($file, $one_time_download, $key, $time, $ip, $crypt, $handle, $name . NL. $mime_type . NL. $size . NL. $password . NL. $time . NL . $hash. NL . ($one_time_download ? 'O' : 'R') . NL . time() . - NL . $ip . NL. $delete_link_code . NL . ($crypted ? 'C' : 'O') + NL . $ip . NL. $delete_link_code . NL . ($crypted ? 'C2' : 'O') ); fclose($handle); $hash_link = substr(base_16_to_64(md5_file($link_tmp_name)), 0, $link_name_length);