@@ -184,6 +186,10 @@ if ($cfg['maximal_upload_size'] >= 1024) {
} else {
echo '
';
}
+if (!empty($cfg['disallowed_extensions'])) {
+ // only shown when the selected file matches, see control_selected_file_extension()
+ echo '
' . t('EXT_LIM') . ' ' . implode(', ', jirafeau_disallowed_extensions($cfg)) . '
';
+}
?>
diff --git a/lib/config.original.php b/lib/config.original.php
index 37c87eb..54be072 100644
--- a/lib/config.original.php
+++ b/lib/config.original.php
@@ -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.
diff --git a/lib/functions.js.php b/lib/functions.js.php
index cafecaf..c468d18 100644
--- a/lib/functions.js.php
+++ b/lib/functions.js.php
@@ -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 += '
' + 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"
diff --git a/lib/functions.php b/lib/functions.php
index 7d00cee..e831087 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -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
";
$out .= "- OS: " . php_uname() . "
";
+ $out .= "- Docker: " . (is_file('/.dockerenv') ? 'yes' : 'no') . "
";
$out .= "
";
$out .= "# Browser details
";
diff --git a/lib/locales/ar.json b/lib/locales/ar.json
index 83227b4..8c7dd01 100644
--- a/lib/locales/ar.json
+++ b/lib/locales/ar.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/be.json b/lib/locales/be.json
index 4dc371c..8a90428 100644
--- a/lib/locales/be.json
+++ b/lib/locales/be.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/bn_IN.json b/lib/locales/bn_IN.json
index c0d7a26..c115719 100644
--- a/lib/locales/bn_IN.json
+++ b/lib/locales/bn_IN.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/bo.json b/lib/locales/bo.json
index 9d08b73..2e3a873 100644
--- a/lib/locales/bo.json
+++ b/lib/locales/bo.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/ca.json b/lib/locales/ca.json
index 2d259b9..31cc56e 100644
--- a/lib/locales/ca.json
+++ b/lib/locales/ca.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/ckb.json b/lib/locales/ckb.json
index bbc76bc..3778d4f 100644
--- a/lib/locales/ckb.json
+++ b/lib/locales/ckb.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/cs.json b/lib/locales/cs.json
index 9db9731..479c51b 100644
--- a/lib/locales/cs.json
+++ b/lib/locales/cs.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/da.json b/lib/locales/da.json
index af0ccb8..08daf4e 100644
--- a/lib/locales/da.json
+++ b/lib/locales/da.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/de.json b/lib/locales/de.json
index 8936ee1..18f487e 100644
--- a/lib/locales/de.json
+++ b/lib/locales/de.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "Nicht erlaubte Dateitypen:",
+ "EXT_NOT_ALLOWED": "Dieser Dateityp ist nicht erlaubt",
"NO": "Nein",
"YES": "Ja",
"ENCRYPTED": "Verschlüsselt",
diff --git a/lib/locales/el.json b/lib/locales/el.json
index 2676b18..e63d83f 100644
--- a/lib/locales/el.json
+++ b/lib/locales/el.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/en.json b/lib/locales/en.json
index f17bf9a..dfef8d5 100644
--- a/lib/locales/en.json
+++ b/lib/locales/en.json
@@ -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.",
diff --git a/lib/locales/es.json b/lib/locales/es.json
index 3c6bac0..3c30602 100644
--- a/lib/locales/es.json
+++ b/lib/locales/es.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "No",
"YES": "SÃ",
"ENCRYPTED": "",
diff --git a/lib/locales/et.json b/lib/locales/et.json
index bbc76bc..3778d4f 100644
--- a/lib/locales/et.json
+++ b/lib/locales/et.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/fi.json b/lib/locales/fi.json
index debff9c..21ecda8 100644
--- a/lib/locales/fi.json
+++ b/lib/locales/fi.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/fr.json b/lib/locales/fr.json
index 8629b76..46cea4e 100644
--- a/lib/locales/fr.json
+++ b/lib/locales/fr.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "Non",
"YES": "Oui",
"ENCRYPTED": "",
diff --git a/lib/locales/he.json b/lib/locales/he.json
index ea0f4e5..19b98d9 100644
--- a/lib/locales/he.json
+++ b/lib/locales/he.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/hi.json b/lib/locales/hi.json
index fdca622..b112888 100644
--- a/lib/locales/hi.json
+++ b/lib/locales/hi.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/hr.json b/lib/locales/hr.json
index d1994d6..2c4c99c 100644
--- a/lib/locales/hr.json
+++ b/lib/locales/hr.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/hu.json b/lib/locales/hu.json
index a4a075e..8632ef5 100644
--- a/lib/locales/hu.json
+++ b/lib/locales/hu.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/id.json b/lib/locales/id.json
index 24cea50..6696234 100644
--- a/lib/locales/id.json
+++ b/lib/locales/id.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/it.json b/lib/locales/it.json
index 4be5d53..262d916 100644
--- a/lib/locales/it.json
+++ b/lib/locales/it.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "No",
"YES": "Sì",
"ENCRYPTED": "",
diff --git a/lib/locales/ja.json b/lib/locales/ja.json
index 04e6735..e81d789 100644
--- a/lib/locales/ja.json
+++ b/lib/locales/ja.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/ko.json b/lib/locales/ko.json
index fdca622..b112888 100644
--- a/lib/locales/ko.json
+++ b/lib/locales/ko.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/la.json b/lib/locales/la.json
index b5cf0a2..a5b7b13 100644
--- a/lib/locales/la.json
+++ b/lib/locales/la.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/mfe.json b/lib/locales/mfe.json
index bbc76bc..3778d4f 100644
--- a/lib/locales/mfe.json
+++ b/lib/locales/mfe.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/ms.json b/lib/locales/ms.json
index 27575f7..670834c 100644
--- a/lib/locales/ms.json
+++ b/lib/locales/ms.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/nb_NO.json b/lib/locales/nb_NO.json
index 939f52b..40d7487 100644
--- a/lib/locales/nb_NO.json
+++ b/lib/locales/nb_NO.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/nl.json b/lib/locales/nl.json
index c817eee..1ff7fc2 100644
--- a/lib/locales/nl.json
+++ b/lib/locales/nl.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/pl.json b/lib/locales/pl.json
index d70f0de..cf13ca9 100644
--- a/lib/locales/pl.json
+++ b/lib/locales/pl.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/ps.json b/lib/locales/ps.json
index bbc76bc..3778d4f 100644
--- a/lib/locales/ps.json
+++ b/lib/locales/ps.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/pt.json b/lib/locales/pt.json
index 812b59d..f93a029 100644
--- a/lib/locales/pt.json
+++ b/lib/locales/pt.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/pt_BR.json b/lib/locales/pt_BR.json
index 1e36b53..145c6c5 100644
--- a/lib/locales/pt_BR.json
+++ b/lib/locales/pt_BR.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/ro.json b/lib/locales/ro.json
index 6d76460..00eb47a 100644
--- a/lib/locales/ro.json
+++ b/lib/locales/ro.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/ru.json b/lib/locales/ru.json
index 6b0f951..98a490b 100644
--- a/lib/locales/ru.json
+++ b/lib/locales/ru.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/sh.json b/lib/locales/sh.json
index bbc76bc..3778d4f 100644
--- a/lib/locales/sh.json
+++ b/lib/locales/sh.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/si.json b/lib/locales/si.json
index 842db6c..e713a3a 100644
--- a/lib/locales/si.json
+++ b/lib/locales/si.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/sk.json b/lib/locales/sk.json
index 8c42dc5..5151b3b 100644
--- a/lib/locales/sk.json
+++ b/lib/locales/sk.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/sl.json b/lib/locales/sl.json
index 463d58b..65dd58b 100644
--- a/lib/locales/sl.json
+++ b/lib/locales/sl.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/sq.json b/lib/locales/sq.json
index bbc76bc..3778d4f 100644
--- a/lib/locales/sq.json
+++ b/lib/locales/sq.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/sr.json b/lib/locales/sr.json
index 6aca55f..e6c2671 100644
--- a/lib/locales/sr.json
+++ b/lib/locales/sr.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/sv.json b/lib/locales/sv.json
index 59c215b..b8778ea 100644
--- a/lib/locales/sv.json
+++ b/lib/locales/sv.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/ta.json b/lib/locales/ta.json
index c46fd97..6116896 100644
--- a/lib/locales/ta.json
+++ b/lib/locales/ta.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/template.json b/lib/locales/template.json
index ce688bf..6b31c4e 100644
--- a/lib/locales/template.json
+++ b/lib/locales/template.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/th.json b/lib/locales/th.json
index bbc76bc..3778d4f 100644
--- a/lib/locales/th.json
+++ b/lib/locales/th.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/tr.json b/lib/locales/tr.json
index 76287db..675bd2a 100644
--- a/lib/locales/tr.json
+++ b/lib/locales/tr.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/uk.json b/lib/locales/uk.json
index bd8f31c..3cddd54 100644
--- a/lib/locales/uk.json
+++ b/lib/locales/uk.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/vi.json b/lib/locales/vi.json
index 35bb24e..52ce1b0 100644
--- a/lib/locales/vi.json
+++ b/lib/locales/vi.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/zh.json b/lib/locales/zh.json
index 5b01550..4811364 100644
--- a/lib/locales/zh.json
+++ b/lib/locales/zh.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/lib/locales/zh_TW.json b/lib/locales/zh_TW.json
index 43877f5..7d08dc5 100644
--- a/lib/locales/zh_TW.json
+++ b/lib/locales/zh_TW.json
@@ -1,4 +1,6 @@
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
diff --git a/script.php b/script.php
index 2fc297f..fdd46e3 100644
--- a/script.php
+++ b/script.php
@@ -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 {