mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Use enshrined\svgSanitize to clean SVG file content
This commit is contained in:
parent
a18b45f0f8
commit
bf2df84d0f
2 changed files with 14 additions and 0 deletions
|
|
@ -38,6 +38,12 @@ class Security
|
|||
if (!utf8_check($input)) return false;
|
||||
return Filters\FilenameFilter::clean($input);
|
||||
|
||||
// Clean up SVG content to prevent various attacks.
|
||||
case 'svg':
|
||||
if (!utf8_check($input)) return false;
|
||||
$sanitizer = new \enshrined\svgSanitize\Sanitizer();
|
||||
return strval($sanitizer->sanitize($input));
|
||||
|
||||
// Unknown filters.
|
||||
default:
|
||||
throw new Exception('Unknown filter type for sanitize: ' . $type);
|
||||
|
|
|
|||
|
|
@ -936,6 +936,14 @@ class FileController extends File
|
|||
}
|
||||
}
|
||||
|
||||
// Sanitize SVG
|
||||
if(!$manual_insert && !$this->user->isAdmin() && ($file_info['type'] === 'image/svg+xml' || $file_info['extension'] === 'svg'))
|
||||
{
|
||||
$dirty_svg = Rhymix\Framework\Storage::read($file_info['tmp_name']);
|
||||
$clean_svg = Rhymix\Framework\Security::sanitize($dirty_svg, 'svg');
|
||||
Rhymix\Framework\Storage::write($file_info['tmp_name'], $clean_svg);
|
||||
}
|
||||
|
||||
// Adjust
|
||||
if(!$manual_insert)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue