Use enshrined\svgSanitize to clean SVG file content

This commit is contained in:
Kijin Sung 2026-02-20 21:55:29 +09:00
parent a18b45f0f8
commit bf2df84d0f
2 changed files with 14 additions and 0 deletions

View file

@ -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);