diff --git a/modules/system/classes/MediaLibrary.php b/modules/system/classes/MediaLibrary.php index 9bf4eaadb5..032ee92e3a 100644 --- a/modules/system/classes/MediaLibrary.php +++ b/modules/system/classes/MediaLibrary.php @@ -1,16 +1,18 @@ -getMediaPath($newPath); + // If the file extension is changed to SVG, ensure that it has been sanitized + $oldExt = pathinfo($oldPath, PATHINFO_EXTENSION); + $newExt = pathinfo($newPath, PATHINFO_EXTENSION); + if ($oldExt !== $newExt && $newExt === 'svg') { + $contents = $this->getStorageDisk()->get($fullOldPath); + $contents = Svg::sanitize($contents); + $this->getStorageDisk()->put($fullOldPath, $contents); + } + return $this->getStorageDisk()->move($fullOldPath, $fullNewPath); }