mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-07 01:03:31 +02:00
fixes GHSA-j9q6-q52g-g8jw make sure SVG files have the appropriate file name extension
This commit is contained in:
@@ -253,6 +253,24 @@ SELECT
|
||||
{
|
||||
$original_extension = strtolower(get_extension($original_filename));
|
||||
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$finfo_type = finfo_file($finfo, $source_filepath);
|
||||
finfo_close($finfo);
|
||||
|
||||
if (in_array($finfo_type, ['image/svg', 'image/svg+xml']) and $original_extension != 'svg')
|
||||
{
|
||||
unlink($source_filepath);
|
||||
$error_msg = 'File extension "'.$original_extension.'" for file "'.$original_filename.'" does not match file MIME type "'.$finfo_type.'"';
|
||||
if (defined('IN_WS'))
|
||||
{
|
||||
global $service;
|
||||
$service->sendResponse(new PwgError(415, $error_msg));
|
||||
exit;
|
||||
}
|
||||
|
||||
die($error_msg);
|
||||
}
|
||||
|
||||
if (in_array($original_extension, $conf['file_ext']))
|
||||
{
|
||||
$file_path.= $original_extension;
|
||||
|
||||
Reference in New Issue
Block a user