From 37a47dbd255874bcdfc14f2e7a5dc1461ddd145e Mon Sep 17 00:00:00 2001 From: Patrick Canterino Date: Sun, 10 Nov 2024 14:03:40 +0100 Subject: [PATCH] Store filesize before encrypting the file This currently applies only for async uploads. Otherwise we would send the size of the encrypted file and the data of the unencrypted file. The encrypted file is usually larger than the unencrypted one. So the browser expects more data and aborts the download because it thinks it didn't receive all the data. --- lib/functions.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/functions.php b/lib/functions.php index 2843e29..9091af7 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1197,6 +1197,11 @@ function jirafeau_async_end($ref, $code, $crypt, $link_name_length, $file_hash_m return "Error: referenced file does not exist"; } + /* Store filesize before encrypting the file */ + /* Otherwise we would send the size of the encrypted file and the data of the unencrypted file */ + /* This would break some browsers */ + $size = filesize($p); + $crypted = false; $crypt_key = ''; if ($crypt == true && extension_loaded('sodium') == true) { @@ -1209,7 +1214,6 @@ function jirafeau_async_end($ref, $code, $crypt, $link_name_length, $file_hash_m } $hash = jirafeau_hash_file($file_hash_method, $p); - $size = filesize($p); $np = s2p($hash); $delete_link_code = jirafeau_gen_random(5); -- 2.34.1