From 01c96e89ef49d3af2895da1650d326a65449c05a Mon Sep 17 00:00:00 2001 From: Nicola Asuni Date: Sat, 26 Oct 2024 12:13:18 +0100 Subject: [PATCH] Merge multiple PRs (#756) * Ayesh: [PHP 8.4] Fix: Curl CURLOPT_BINARYTRANSFER deprecated #675 * THenkeDE: SVG detection fix for inline data images #646 * bruno-farias: Fix count svg #647 --- include/tcpdf_static.php | 1 - tcpdf.php | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 4cee355e..395bb958 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -1961,7 +1961,6 @@ public static function fileGetContents($file) { // try to get remote file data using cURL $crs = curl_init(); curl_setopt($crs, CURLOPT_URL, $path); - curl_setopt($crs, CURLOPT_BINARYTRANSFER, true); curl_setopt($crs, CURLOPT_FAILONERROR, true); curl_setopt($crs, CURLOPT_RETURNTRANSFER, true); if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) { diff --git a/tcpdf.php b/tcpdf.php index 1abf622a..af5beb97 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -19055,7 +19055,7 @@ protected function openHTMLTagHandler($dom, $key, $cell) { if ($imgsrc[0] === '@') { // data stream $imgsrc = '@'.base64_decode(substr($imgsrc, 1)); - $type = ''; + $type = preg_match('/]*)>/si', $imgsrc) ? 'svg' : ''; } else if (preg_match('@^data:image/([^;]*);base64,(.*)@', $imgsrc, $reg)) { $imgsrc = '@'.base64_decode($reg[2]); $type = $reg[1]; @@ -23445,8 +23445,8 @@ protected function setSVGStyles($svgstyle, $prevsvgstyle, $x=0, $y=0, $w=1, $h=1 $cy -= $h; } $this->_out(sprintf('%F 0 0 %F %F %F cm', ($w * $this->k), ($h * $this->k), ($x * $this->k), ($cy * $this->k))); - if (count($gradient['stops']) > 1) { - $this->Gradient($gradient['type'], $gradient['coords'], $gradient['stops'], array(), false); + if ((is_array($gradient['stops']) || $gradient['stops'] instanceof Countable) && count($gradient['stops']) > 1) { + $this->Gradient($gradient['type'], $gradient['coords'], $gradient['stops']); } } elseif ($svgstyle['fill'] != 'none') { $fill_color = TCPDF_COLORS::convertHTMLColorToDec($svgstyle['fill'], $this->spot_colors);