Fix problema di sicurezza upload file svg e xml

This commit is contained in:
loviuz 2021-07-04 20:02:16 +02:00
parent 9011409cc1
commit 7ec0bbe4bb
2 changed files with 65 additions and 56 deletions

View File

@ -206,7 +206,7 @@ class Upload extends Model
*/
public function isImage()
{
$list = ['jpg', 'png', 'gif', 'jpeg', 'bmp'];
$list = ['jpg', 'png', 'gif', 'jpeg', 'bmp', 'svg'];
return in_array($this->extension, $list);
}

View File

@ -29,7 +29,15 @@ if (empty($file)) {
$link = base_path().'/'.$file->filepath;
if ($file->isFatturaElettronica()) {
// Force download of the file
if (get('force') == '1') {
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"" . basename($file->original_name) . "\"");
readfile($docroot.'/'.$file->filepath);
exit();
} else {
if ($file->isFatturaElettronica()) {
$content = file_get_contents(base_dir().'/'.$file->filepath);
// Individuazione stylesheet
@ -56,16 +64,16 @@ if ($file->isFatturaElettronica()) {
$xslt->importStylesheet($xsl);
echo '
<style>
<style>
#notifica {
min-width: 860px !important;
}
</style>';
</style>';
echo $xslt->transformToXML($xml);
} else {
} else {
echo '
<style>
<style>
body, iframe, img{
border: 0;
margin: 0;
@ -76,7 +84,7 @@ if ($file->isFatturaElettronica()) {
height:100%;
min-height: 500px;
}
</style>';
</style>';
if ($file->isImage()) {
echo '
@ -87,8 +95,9 @@ if ($file->isFatturaElettronica()) {
}
echo '
<iframe src="'.($link ?: $src).'">
<a src="'.$link.'">'.tr('Il browser non supporta i contenuti iframe: clicca qui per raggiungere il file originale').'</a>
<iframe src="'.base_path().'/view.php?file_id='.$file_id.'&force=1">
<a src="'.base_path().'/view.php?file_id='.$file_id.'&force=1">'.tr('Il browser non supporta i contenuti iframe: clicca qui per raggiungere il file originale').'</a>
</iframe>';
}
}
}