+lib/config.local.php
screenshots
AUTHORS.md
CHANGELOG.md
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
- Cem
- Dan Untenzu
- Dark Horse
+- Davi Torres
- Dennis de Best
- Edwin Bos
- Erik Hubers
- Mathis Mensing
- Matthieu Schneider
- Mattias Münster
+- Max Hausch
- max keiser
- Michal Čihař
- Milo Ivir
- Zertrin
- Zoltán Faludi
- Степанчук Максим
-- Слободан Симић
\ No newline at end of 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
- `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
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');
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);
}
}
+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;
?>
} 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">
} 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>
*/
$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.
// 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"
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
$out .= "# OS details<br/>";
$out .= "- OS: " . php_uname() . "<br/>";
+ $out .= "- Docker: " . (is_file('/.dockerenv') ? 'yes' : 'no') . "<br/>";
$out .= "<br/>";
$out .= "# Browser details<br/>";
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "Nicht erlaubte Dateitypen:",
+ "EXT_NOT_ALLOWED": "Dieser Dateityp ist nicht erlaubt",
"NO": "Nein",
"YES": "Ja",
"ENCRYPTED": "Verschlüsselt",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
"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.",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "No",
"YES": "Sí",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "Non",
"YES": "Oui",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "No",
"YES": "Sì",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
{
+ "EXT_LIM": "",
+ "EXT_NOT_ALLOWED": "",
"NO": "",
"YES": "",
"ENCRYPTED": "",
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.';
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;
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 {