]> git.p6c8.net - jirafeau/jirafeau.git/commitdiff
Merge branch 'allow-disallow-extensions' into 'next-release'
authorBlackeye <14815724-Blackstareye@users.noreply.gitlab.com>
Sat, 31 Oct 2026 00:32:20 +0000 (01:32 +0100)
committerBlackeye <14815724-Blackstareye@users.noreply.gitlab.com>
Sat, 31 Oct 2026 00:32:20 +0000 (01:32 +0100)
Add a config option to forbid certain file extensions for uploads

See merge request jirafeau/Jirafeau!39

1  2 
script.php

diff --combined script.php
index bcca4f78c48236e520d7b953875b57ff733b0173,671aeef331d9908dc527103358cb03437a9a2b24..39eb9d2a54c04c7485de944b6e78afda1af1af97
@@@ -94,9 -94,7 +94,9 @@@ if (isset($_FILES['file']) && is_writab
          exit;
      }
  
 -    if (!isset($_POST['time']) || !$cfg['availabilities'][$_POST['time']]) {
 +    if (!isset($_POST['time'])) {
 +        $time = jirafeau_datestr_to_int($cfg['availability_default']);
 +    } elseif (!$cfg['availabilities'][$_POST['time']]) {
          echo 'Error 4: The parameter time is invalid.';
          exit;
      } else {
          exit;
      }
  
+     // Check file extension
+     if (!jirafeau_is_extension_allowed($cfg, $_FILES['file']['name'])) {
+         echo 'Error 27: This file extension is not allowed.';
+         exit;
+     }
+ 
      // Check if one time download is enabled
      if (!$cfg['one_time_download'] && isset($_POST['one_time_download'])) {
          echo 'Error 26: One time download is disabled.';
@@@ -418,6 -422,12 +424,12 @@@ elseif (isset($_GET['init_async'])) 
          exit;
      }
  
+     // Check file extension
+     if (!jirafeau_is_extension_allowed($cfg, $_POST['filename'])) {
+         echo 'Error 28: This file extension is not allowed.';
+         exit;
+     }
+ 
      $type = '';
      if (isset($_POST['type'])) {
          $type = $_POST['type'];
          exit;
      }
  
 -    if (!isset($_POST['time']) || !$cfg['availabilities'][$_POST['time']]) {
 +    if (!isset($_POST['time'])) {
 +        $time = jirafeau_datestr_to_int($cfg['availability_default']);
 +    } elseif (!$cfg['availabilities'][$_POST['time']]) {
          echo 'Error 22';
          exit;
      } else {

patrick-canterino.de