]> git.p6c8.net - jirafeau/jirafeau.git/commitdiff
Merge branch 'fix_issue_51' into next-release
authorPatrick Canterino <patrick@patrick-canterino.de>
Fri, 13 Nov 2026 18:32:45 +0000 (19:32 +0100)
committerPatrick Canterino <patrick@patrick-canterino.de>
Fri, 13 Nov 2026 18:32:45 +0000 (19:32 +0100)
61 files changed:
.dockerignore
.gitlab-ci.yml
AUTHORS.md
CHANGELOG.md
docker/README.md
docker/docker_config.php
f.php
index.php
lib/config.original.php
lib/functions.js.php
lib/functions.php
lib/locales/ar.json
lib/locales/be.json
lib/locales/bn_IN.json
lib/locales/bo.json
lib/locales/ca.json
lib/locales/ckb.json
lib/locales/cs.json
lib/locales/da.json
lib/locales/de.json
lib/locales/el.json
lib/locales/en.json
lib/locales/es.json
lib/locales/et.json
lib/locales/fi.json
lib/locales/fr.json
lib/locales/he.json
lib/locales/hi.json
lib/locales/hr.json
lib/locales/hu.json
lib/locales/id.json
lib/locales/it.json
lib/locales/ja.json
lib/locales/ko.json
lib/locales/la.json
lib/locales/mfe.json
lib/locales/ms.json
lib/locales/nb_NO.json
lib/locales/nl.json
lib/locales/pl.json
lib/locales/ps.json
lib/locales/pt.json
lib/locales/pt_BR.json
lib/locales/ro.json
lib/locales/ru.json
lib/locales/sh.json
lib/locales/si.json
lib/locales/sk.json
lib/locales/sl.json
lib/locales/sq.json
lib/locales/sr.json
lib/locales/sv.json
lib/locales/ta.json
lib/locales/template.json
lib/locales/th.json
lib/locales/tr.json
lib/locales/uk.json
lib/locales/vi.json
lib/locales/zh.json
lib/locales/zh_TW.json
script.php

index 670c26893cd23f95d0ab20a04dc9ca08530b7a59..ce2495922ce079d66a526fe8988b85e940c6bc10 100644 (file)
@@ -1,3 +1,4 @@
+lib/config.local.php
 screenshots
 AUTHORS.md
 CHANGELOG.md
index 613ab9b6e3d819a399ed152c4000ba77d8bc8c47..1a8d24e117b392cf2d6fdf6efd01a9827791980a 100644 (file)
@@ -63,15 +63,6 @@ job_lint_app_81:
   before_script: *before_linter_script
   script: *linter_script
   <<: *linter_warning
-  
-
-
-# Run tests for php:7.4
-job_lint_app_74:
-  image: php:7.4
-  before_script: *before_linter_script
-  script: *linter_script
-  <<: *linter_warning
 
 # =================
 # Deprecated ones END
index 9eaa5e5b785c2775ff4e28599435715058eae969..84f5110f575dcee74436a0031c70f2e8ed27f6ea 100644 (file)
@@ -23,6 +23,7 @@ This is a list of people who contributed to Jirafeau over the years. The list wa
 - Cem
 - Dan Untenzu
 - Dark Horse
+- Davi Torres
 - Dennis de Best
 - Edwin Bos
 - Erik Hubers
@@ -68,6 +69,7 @@ This is a list of people who contributed to Jirafeau over the years. The list wa
 - Mathis Mensing
 - Matthieu Schneider
 - Mattias Münster
+- Max Hausch
 - max keiser
 - Michal Čihař
 - Milo Ivir
@@ -120,4 +122,4 @@ This is a list of people who contributed to Jirafeau over the years. The list wa
 - Zertrin
 - Zoltán Faludi
 - Степанчук Максим
-- Слободан Симић
\ No newline at end of file
+- Слободан Симић
index a85065ce8f489c14f4124d11e0c996334d286a4d..c4634371fb91260680d254282a248f9b3757f56a 100644 (file)
 
 ## Version 4.7.x (not yet released)
 
+- Download stats are written before a one-time link is deleted. The other way around would cause write attempts to a directory that was already gone.
+- The `time` parameter is now optional in `script.php`
+- Few little more fixes and refactoring
 - ...
+- Upgrade from 4.7.2: in-place upgrade
 
 ## Version 4.7.2
 
index d170d70747b1867216f5087519df248445ca9a05..619772a01eba56aa2897b42c385997e14d6034e5 100644 (file)
@@ -101,6 +101,7 @@ Available options:
 - `UPLOAD_IP`: set one or more ip allowed to upload files (separated by comma).
 - `UPLOAD_IP_NO_PASSWORD`: set one or more ip allowed to upload files without password (separated by comma).
 - `PROXY_IP`: set one or more proxy ip (separated by comma).
+- `DISALLOWED_EXTENSIONS`: forbid specific file extensions from being uploaded (separated by comma).
 - `STORE_UPLOADER_IP`: set to 1 or 0 to enable or disable keeping sender's IP with the _link_ file.
 - `DOWNLOAD_PASSWORD_REQUIREMENT`: set to 'optional' (default), 'required' or 'generated' to make a password for downloading optional, required or generated
 - `DOWNLOAD_PASSWORD_GEN_LEN`: set length of generated download passwords
index d814a8e678303c029f31bb1adf7d72dfcc6184b7..c589a13508371b17246ebbe18ad654b0881b9231 100644 (file)
@@ -201,6 +201,7 @@ function run_setup(&$cfg)
     env_2_cfg_string_array($cfg, 'admin_ip');
     env_2_cfg_string_array($cfg, 'upload_ip_nopassword');
     env_2_cfg_string_array($cfg, 'proxy_ip');
+    env_2_cfg_string_array($cfg, 'disallowed_extensions');
     // this is a key value based value
     env_2_cfg_array_from_json($cfg, 'availabilities');
     env_2_cfg_bool($cfg, 'store_uploader_ip');
diff --git a/f.php b/f.php
index 352359668f61c4cf7b4b1a06f1d019df7ca77ed5..13fe280f06386f4d3697afe74ead3d2b37a2d7e9 100644 (file)
--- a/f.php
+++ b/f.php
@@ -171,9 +171,13 @@ if (!empty($link['key'])) {
         require(JIRAFEAU_ROOT.'lib/template/footer.php');
         exit;
     } else {
-        if (strpos($link['key'], '[SHA256]') == 0 && hash_equals(substr($link['key'], 8), hash('sha256', $_POST['key']))) {
+        $sha_hash_compare = strpos($link['key'], '[SHA256]') === 0 && hash_equals(substr($link['key'], 8), hash('sha256', $_POST['key']));
+        // legacy md5 compare - before prefixing
+        $md5_legacy_hash_compare = hash_equals($link['key'], md5($_POST['key']));
+
+        if ( $sha_hash_compare ) {
             $password_challenged = true;
-        } elseif (hash_equals($link['key'], md5($_POST['key']))) {
+        } elseif ( $md5_legacy_hash_compare ) {
             $password_challenged = true;
         } else {
             sleep(2);
@@ -274,12 +278,12 @@ else {
     }
 }
 
+jirafeau_write_download_stats($link_name, get_ip_address($cfg));
+
 if ($link['onetime'] == 'O') {
     jirafeau_delete_link($link_name);
 }
 
-jirafeau_write_download_stats($link_name, get_ip_address($cfg));
-
 exit;
 
 ?>
index d60cb1809dfebb56b6e8f8295ca6b054d6e43269..454bc5209e2721de4b5d7dea694d7f67e386791e 100644 (file)
--- a/index.php
+++ b/index.php
@@ -136,7 +136,9 @@ elseif (true === jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) {
             } elseif ($cfg['maximal_upload_size'] > 0) {
                 echo t('2_BIG') . ', ' . t('FILE_LIM') . " " . $cfg['maximal_upload_size'] . " MB.";
             }
-?>')"/>
+?>'); control_selected_file_extension(<?php
+            echo jirafeau_escape(json_encode(jirafeau_disallowed_extensions($cfg)));
+?>, '<?php echo t('EXT_NOT_ALLOWED'); ?>.')"/>
     </p>
 
     <div id="options">
@@ -184,6 +186,10 @@ if ($cfg['maximal_upload_size'] >= 1024) {
 } else {
     echo '<p class="config"></p>';
 }
+if (!empty($cfg['disallowed_extensions'])) {
+    // only shown when the selected file matches, see control_selected_file_extension()
+    echo '<p id="disallowed_extensions" class="config" style="display: none">' . t('EXT_LIM') . ' ' . implode(', ', jirafeau_disallowed_extensions($cfg)) . '</p>';
+}
 ?>
 
         <p id="max_file_size" class="config"></p>
index 37c87ebc573d6d6db4637d2c815c658980291c5c..54be072a05b753f468ba7c3f1e42f6caf95d7700 100644 (file)
@@ -170,6 +170,15 @@ $cfg['one_time_download_preselected'] = false;
  */
 $cfg['maximal_upload_size'] = 0;
 
+/* Forbid specific file extensions from being uploaded.
+ * Leave empty to allow every extension.
+ * Extensions are matched case-insensitively; a leading dot is optional.
+ * Compound extensions such as 'tar.gz' are supported. Note that 'gz'
+ * also covers 'tar.gz', while 'tar.gz' leaves plain '.gz' files allowed.
+ * $cfg['disallowed_extensions'] = array('exe', 'bat', 'sh', 'php', 'tar.gz');
+ */
+$cfg['disallowed_extensions'] = array();
+
 /* Proxy IP
  * If the installation is behind some reverse proxies, it is possible to set
  * the allowed proxy IP.
index cafecafcdc0f6fcd19ade0b89944ec80c86daad8..c468d181c5f8aa8330f22e95ae717a3c9880282c 100644 (file)
@@ -346,11 +346,45 @@ function control_selected_file_size(max_size, error_str)
         // display options
         document.getElementById('options').style.display = 'block';
         document.getElementById('send').style.display = 'block';
+        document.getElementById('send').disabled = false;
         document.getElementById('error_pop').style.display = 'none';
         document.getElementById('send').focus();
     }
 }
 
+// UX-only: script.php enforces disallowed_extensions independently, this
+// just warns the user before they submit a doomed upload.
+function control_selected_file_extension(disallowed_extensions, error_str)
+{
+    if (disallowed_extensions.length === 0)
+    {
+        return;
+    }
+    f_name = document.getElementById('file_select').files[0].name.replace(/[\s.]+$/, '').toLowerCase();
+    // suffix match so that compound extensions such as 'tar.gz' work too
+    if (disallowed_extensions.some(function (ext) { return f_name.endsWith('.' + ext); }))
+    {
+        // control_selected_file_size runs first: keep its error, if any, and add ours
+        var error_pop = document.getElementById('error_pop');
+        if (error_pop.style.display === 'none')
+        {
+            pop_failure(error_str);
+        }
+        else
+        {
+            error_pop.innerHTML += '<br />' + error_str;
+        }
+        // keep the button visible but disabled so the user sees it is forbidden
+        document.getElementById('send').style.display = 'block';
+        document.getElementById('send').disabled = true;
+        document.getElementById('disallowed_extensions').style.display = 'block';
+    }
+    else
+    {
+        document.getElementById('disallowed_extensions').style.display = 'none';
+    }
+}
+
 function XHRErrorHandler(e)
 {
     var text = "${e.type}: ${e.loaded} bytes transferred"
index 7d00ceefb94caef172c1e0a3f0212a23d22223a2..e83108747ce19e6459ded436645a6c1fff1e0a4e 100644 (file)
@@ -229,6 +229,58 @@ function jirafeau_ini_to_bytes($value)
     return $bytes;
 }
 
+/**
+ * returns the configured disallowed extensions, lower-cased and without
+ * a leading dot
+ * @param $cfg jirafeau config
+ * @returns array of normalized extensions
+ */
+function jirafeau_disallowed_extensions($cfg)
+{
+    if (empty($cfg['disallowed_extensions'])) {
+        return array();
+    }
+
+    // tolerate a leading dot in the config, e.g. '.jpg' instead of 'jpg'
+    $extensions = array();
+    foreach ($cfg['disallowed_extensions'] as $extension) {
+        $extension = ltrim(strtolower(trim($extension)), '.');
+        if ($extension !== '') {
+            $extensions[] = $extension;
+        }
+    }
+
+    return $extensions;
+}
+
+/**
+ * checks if a file name's extension is allowed to be uploaded
+ * @param $cfg jirafeau config
+ * @param $filename the name of the file being uploaded
+ * @returns true if the extension is allowed
+ */
+function jirafeau_is_extension_allowed($cfg, $filename)
+{
+    $extensions = jirafeau_disallowed_extensions($cfg);
+    if (empty($extensions)) {
+        return true;
+    }
+
+    // trailing dots and whitespace are dropped on storage or by the client OS
+    $filename = strtolower(rtrim($filename, " \t\n\r\0\v."));
+
+    // suffix match so that compound extensions such as 'tar.gz' work too;
+    // 'gz' still covers 'archive.tar.gz'
+    foreach ($extensions as $extension) {
+        $suffix = '.' . $extension;
+        if (substr($filename, -strlen($suffix)) === $suffix) {
+            return false;
+        }
+    }
+
+    return true;
+}
+
 /**
  * gets the maximum upload size according to php.ini
  * @returns the maximum upload size in bytes
@@ -996,6 +1048,7 @@ function jirafeau_admin_bug_report($cfg)
 
     $out .= "# OS details<br/>";
     $out .= "- OS: " . php_uname() . "<br/>";
+    $out .= "- Docker: " . (is_file('/.dockerenv') ? 'yes' : 'no') . "<br/>";
     $out .= "<br/>";
 
     $out .= "# Browser details<br/>";
index 83227b40cb5519cef6a3fc97d6a370cca68fb036..8c7dd01030e0d25915256a3501380ed33db3ecd0 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 4dc371c2954d395b8426fbe5d656387e99fb682f..8a90428b3f1b47025bbc271fa0ab6181cf3824f8 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index c0d7a26660c7deb2d32b9bce1f541f81475584b8..c11571944cff114ff0646306bd5e9a63ee0ce55b 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 9d08b73b4a7b1025b8ef9d154bb56e1e9309add4..2e3a873b2571edb174fc1238ddc0e5aeef55fdf6 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 2d259b9741d3909b8c5944a7d9d59c8279705c8d..31cc56e4cd7dbec4f2b6ba8d87d7eb3072d22842 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index bbc76bc8e975288cc512417937fbaac36ea203b4..3778d4f4a406076fe5183b67549f1595d9e52be8 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 9db9731ff5b42c35ca1804cac072efda604e8213..479c51b37e57ec5815c34ff4ba55f7bde9c0e21a 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index af0ccb848bba81b2555099a65292b37050e17d9b..08daf4eda60f30d0bb9ea6a8fb042e3950cab299 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 8936ee124a91134c031a23bacf228f246945f342..18f487ee454da4c51fd6bd8b605bc22701d7f2b8 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "Nicht erlaubte Dateitypen:",
+    "EXT_NOT_ALLOWED": "Dieser Dateityp ist nicht erlaubt",
     "NO": "Nein",
     "YES": "Ja",
     "ENCRYPTED": "Verschlüsselt",
index 2676b18dc325809d71225b70d2138175a68f25a2..e63d83f999d6c2aee39cc6f4b01e725ad484fb00 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index f17bf9ac211dd04596616d4c74816f577b26f802..dfef8d5f3e41f62df0e3bc7d2181f0c13100b90c 100644 (file)
@@ -38,6 +38,8 @@
     "UP_PSW": "Upload password",
     "2_BIG": "The file is too big",
     "FILE_LIM": "File size limited to",
+    "EXT_NOT_ALLOWED": "This file extension is not allowed",
+    "EXT_LIM": "Disallowed file extensions:",
     "FILE_DIR_W": "The file directory is not writable.",
     "LINK_DIR_W": "The link directory is not writable.",
     "ASYNC_DIR_W": "The async directory is not writable.",
index 3c6bac010eefc7f7a117f30df676a6c247868955..3c30602182ee6fd3ce9c90edf25c08ef99c3ac5c 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "No",
     "YES": "Sí",
     "ENCRYPTED": "",
index bbc76bc8e975288cc512417937fbaac36ea203b4..3778d4f4a406076fe5183b67549f1595d9e52be8 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index debff9c7de7b5367d3890fd4e8a0ea84936ae22c..21ecda83290b706b39135b3fe97c7d6f1e73959d 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 8629b761453e2975193f5e1985bfd7b98c0660ea..46cea4ea082346b99346176ac63ee3a87278469e 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "Non",
     "YES": "Oui",
     "ENCRYPTED": "",
index ea0f4e55a8b3950c28d2da3201c7e4f161999324..19b98d9abfd7b1644cdd2d63e3e81a10a441d11e 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index fdca6222f49936c15aca593d3826f558872ea313..b1128882ca5598ff4c26e0aef88b330e28ec82d6 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index d1994d6a1e7659721fa29443bb10b3a153a81032..2c4c99c6183f1ff6bdce165d32043cd6a7788702 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index a4a075ec720adc21845bb236fd3855ee03a2b5aa..8632ef5d406ba2adf2180cf02499551fb039bb34 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 24cea5082702fb87bfc7b4a757dc735fd22eadd9..66962341cd924830c331b648126ded61a0cca21f 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 4be5d535d624f339d03bcd5ffe6e72c0e229d894..262d916d2f7794bec3d26b947d2bc1bdc65d31ab 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "No",
     "YES": "Sì",
     "ENCRYPTED": "",
index 04e67359bcb161c782e7f2cb1f105bc44233785e..e81d7898417dcc80fad7e37faa2557e04ea1f52d 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index fdca6222f49936c15aca593d3826f558872ea313..b1128882ca5598ff4c26e0aef88b330e28ec82d6 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index b5cf0a26aeb3e6a1a59984591185bba31eccac2a..a5b7b13ee467720eb769b7de83a616dfbb520325 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index bbc76bc8e975288cc512417937fbaac36ea203b4..3778d4f4a406076fe5183b67549f1595d9e52be8 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 27575f76f20e8b5aa5b29d52d187641eb90b4f83..670834ce57995d7ac198e975d3656cb1dd40f6c2 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 939f52be458b7ba30489660da4e22e2411bbdd14..40d7487ce6a537e30e9f3ad1c6e86324e1cce8f8 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index c817eee7358c94255f0b740b17bc459ee8995056..1ff7fc290d2f5fac2748fb99d8e7896a211946d3 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index d70f0dec1e3e0889f1c0a98b06c44537ddec87a5..cf13ca9600dcd39137e11805cb2194a5711748de 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index bbc76bc8e975288cc512417937fbaac36ea203b4..3778d4f4a406076fe5183b67549f1595d9e52be8 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 812b59d1ee40d9b375bfdb76710400d9eaf678da..f93a0294c200f5ee92ddbeeb1a7c60c19c20ad38 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 1e36b53959ae012cb0ce2a7997edbd9488ca6bb3..145c6c57419115724cf3f57ddf14ef7fde0d1736 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 6d76460dfc617239d42ed7df3e4ee7541954ab2f..00eb47a3bad4098ec92a30353c089b05b8330733 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 6b0f95182e2b6d472f2fd16fa27c8e776bb6e165..98a490ba0335c85722f3d19e6b443bd127976307 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index bbc76bc8e975288cc512417937fbaac36ea203b4..3778d4f4a406076fe5183b67549f1595d9e52be8 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 842db6c66f61001db0ac0c0eaa115cc4dc27cb70..e713a3a9e79a0c38f9d0dc8c0b71de1522d262b1 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 8c42dc5fb8f65af0350d0cdc50150d6b4de0f774..5151b3b9e1777a15b74a2d1d94803b1fda63c085 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 463d58b7114060198ec1e84fcf6f294e32834b72..65dd58b3adf2adb735a5cb87419fa2a95103a968 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index bbc76bc8e975288cc512417937fbaac36ea203b4..3778d4f4a406076fe5183b67549f1595d9e52be8 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 6aca55ffa26de13c3ef486f220edce3befde64ab..e6c2671e52694bcd39260ab9e8a3facf6ba66ce9 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 59c215bb4534f1694fccac2069ce0579a1ae8bf9..b8778eaee93c606ae844f5241e1f4709b72166ef 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index c46fd974fd1fa9472fa2e1f0f8c2c88c6be1532e..61168965b755e321513e980a1a0c03dc226ff1ce 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index ce688bf7f3766a0372c5ab926482e53dba0930da..6b31c4ee09805d4e70dd8845c5af8051e8ae1cd7 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index bbc76bc8e975288cc512417937fbaac36ea203b4..3778d4f4a406076fe5183b67549f1595d9e52be8 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 76287db6dee8fff6bb283ca0ec387ebb4c8d190e..675bd2a7b3efa3c439eadf025895784461ebfdff 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index bd8f31c32b8a2aa56773b673945970a6d352783a..3cddd54cba25f0635a78cafeb94ce6826bb4f7d6 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 35bb24eb6d503cfffb438e042e2dd54b9b77d3b6..52ce1b011019bb916a350e359bdf1141a533aea6 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 5b01550a475304c4eb224644f81365dfac3e1ffc..48113648d0bf33ae64138d35b479777d9af107b7 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 43877f5a7ee28440ea33d112c5aac671253fb14b..7d08dc5b833e16843efbddede8ae733b460337fe 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "EXT_LIM": "",
+    "EXT_NOT_ALLOWED": "",
     "NO": "",
     "YES": "",
     "ENCRYPTED": "",
index 2fc297f3412302a0933ef91d3d85f82560c49df9..fdd46e3850de7d5d017eb5675f8cf12b10cc7caa 100644 (file)
@@ -94,7 +94,9 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES)
         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 {
@@ -108,6 +110,12 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES)
         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.';
@@ -183,7 +191,12 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES)
         echo 'Error 9';
         exit;
     }
-    if (strlen($link['key']) > 0 && hash('sha256', $key) != $link['key']) {
+    // sha hash compare
+    $sha_hash_compare = (strpos($link['key'], '[SHA256]') === 0 && hash_equals(substr($link['key'], 8), hash('sha256', $key)));
+    // legacy md5 compare - before prefixing
+    $md5_legacy_hash_compare = hash_equals($link['key'], md5($key));
+    
+    if (strlen($link['key']) > 0 && !$sha_hash_compare && !$md5_legacy_hash_compare ) {
         sleep(2);
         echo 'Error 10';
         exit;
@@ -416,6 +429,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'];
@@ -441,7 +460,9 @@ elseif (isset($_GET['init_async'])) {
         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