Scramble foreignObject in SVG files

This commit is contained in:
the-djmaze 2026-10-22 18:19:52 +02:00
parent 61ebcb6ed4
commit 57de7eed1a

View file

@ -219,14 +219,21 @@ trait Raw
\header('Content-Transfer-Encoding: binary');
}
// https://github.com/the-djmaze/snappymail/security/advisories/GHSA-cjq6-6gwv-qxjj
$bSVG = ('image/svg+xml' === $sContentType) || ('.svg' === \substr($sFileName, -4));
$sLoadedData = null;
if ($bIsRangeRequest || !$bDownload) {
if ($bIsRangeRequest || !$bDownload || $bSVG) {
$sLoadedData = \stream_get_contents($rResource);
}
\MailSo\Base\Utils::ResetTimeLimit();
if ($sLoadedData) {
if ($bSVG) {
$sLoadedData = \str_replace('foreignObject' ,'foreign-Object', $sLoadedData);
}
if ($bIsRangeRequest && (\strlen($sRangeStart) || \strlen($sRangeEnd))) {
$iFullContentLength = \strlen($sLoadedData);