diff --git a/src/MicroweberPackages/App/functions/plupload.php b/src/MicroweberPackages/App/functions/plupload.php index 244980968ce..5890b2ae9ff 100644 --- a/src/MicroweberPackages/App/functions/plupload.php +++ b/src/MicroweberPackages/App/functions/plupload.php @@ -563,17 +563,25 @@ } } else if ($ext === 'svg') { - + $valid = false; if (is_file($filePath)) { $sanitizer = new \enshrined\svgSanitize\Sanitizer(); // Load the dirty svg $dirtySVG = file_get_contents($filePath); // Pass it to the sanitizer and get it back clean - $cleanSVG = $sanitizer->sanitize($dirtySVG); - file_put_contents($filePath, $cleanSVG); + try { + $cleanSVG = $sanitizer->sanitize($dirtySVG); + $valid = true; + } catch (\Exception $e) { + $valid = false; + } + + if ($valid) { + file_put_contents($filePath, $cleanSVG); + } } - $valid = true; + } else { $valid = false;