]> git.p6c8.net - jirafeau/jirafeau.git/commitdiff
Merge branch 'fix_legacy_upload' into 'next-release'
authorPatrick Canterino <patrick@patrick-canterino.de>
Fri, 5 Jun 2026 14:02:08 +0000 (16:02 +0200)
committerPatrick Canterino <patrick@patrick-canterino.de>
Fri, 5 Jun 2026 14:02:08 +0000 (16:02 +0200)
Fixed file encryption on classic upload

See merge request jirafeau/Jirafeau!34

lib/config.original.php
lib/functions.js.php
lib/functions.php

index 6b7c342e51cf7a1402774266016c0862f14a770c..37c87ebc573d6d6db4637d2c815c658980291c5c 100644 (file)
@@ -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).
index 29d50c198edfbc321a0d1855eadd8624f4baa15b..cafecafcdc0f6fcd19ade0b89944ec80c86daad8 100644 (file)
@@ -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 ()
 {
+<?php
+    if (isset($cfg['debug_enforce_classic_upload']) && $cfg['debug_enforce_classic_upload']) { ?>
+    // Enforce classic upload is enabled through config!
+    return false;
+<?php
+    }
+?>
     return window.File && window.FileReader && window.FileList && window.Blob;
 }
 
index 833e21b7d640606687fa3ab9802defeee084061f..948a436de4843bd28f1b1210e1fcc3f379a8923f 100644 (file)
@@ -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);

patrick-canterino.de