FIX Force downlaod of file with .noexe as octet-stream mime type
This commit is contained in:
parent
b5c5cc42fc
commit
9cfe1262bd
@ -159,6 +159,8 @@ if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
|
|||||||
$type = 'application/octet-stream';
|
$type = 'application/octet-stream';
|
||||||
if (GETPOST('type', 'alpha')) $type=GETPOST('type', 'alpha');
|
if (GETPOST('type', 'alpha')) $type=GETPOST('type', 'alpha');
|
||||||
else $type=dol_mimetype($original_file);
|
else $type=dol_mimetype($original_file);
|
||||||
|
// Security: Force to octet-stream if file is a dangerous file
|
||||||
|
if (preg_match('/\.noexe$/i', $original_file)) $type = 'application/octet-stream';
|
||||||
|
|
||||||
// Security: Delete string ../ into $original_file
|
// Security: Delete string ../ into $original_file
|
||||||
$original_file = str_replace("../", "/", $original_file);
|
$original_file = str_replace("../", "/", $original_file);
|
||||||
@ -215,7 +217,7 @@ if (! $accessallowed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Security:
|
// Security:
|
||||||
// On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers.
|
// We refuse directory transversal change and pipes in file names
|
||||||
if (preg_match('/\.\./', $fullpath_original_file) || preg_match('/[<>|]/', $fullpath_original_file))
|
if (preg_match('/\.\./', $fullpath_original_file) || preg_match('/[<>|]/', $fullpath_original_file))
|
||||||
{
|
{
|
||||||
dol_syslog("Refused to deliver file ".$fullpath_original_file);
|
dol_syslog("Refused to deliver file ".$fullpath_original_file);
|
||||||
@ -227,6 +229,7 @@ if (preg_match('/\.\./', $fullpath_original_file) || preg_match('/[<>|]/', $full
|
|||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
$filename = basename($fullpath_original_file);
|
$filename = basename($fullpath_original_file);
|
||||||
|
$filename = preg_replace('/\.noexe$/i', '', $filename);
|
||||||
|
|
||||||
// Output file on browser
|
// Output file on browser
|
||||||
dol_syslog("document.php download $fullpath_original_file filename=$filename content-type=$type");
|
dol_syslog("document.php download $fullpath_original_file filename=$filename content-type=$type");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user