improve SVG detection by checking for (mandatory) namespace and closing tag

This commit is contained in:
Manuel Capinha 2024-11-26 11:54:15 +00:00
parent cfbc0028cc
commit 122a2c61dc

View File

@ -19055,7 +19055,7 @@ class TCPDF {
if ($imgsrc[0] === '@') {
// data stream
$imgsrc = '@'.base64_decode(substr($imgsrc, 1));
$type = preg_match('/<svg([^\>]*)>/si', $imgsrc) ? 'svg' : '';
$type = preg_match('/<svg\s+[^>]*\bxmlns\s*=\s*"http:\/\/www\.w3\.org\/2000\/svg"[^>]*>.*<\/svg>/is', $imgsrc) ? 'svg' : '';
} else if (preg_match('@^data:image/([^;]*);base64,(.*)@', $imgsrc, $reg)) {
$imgsrc = '@'.base64_decode($reg[2]);
$type = $reg[1];