From c8414c67ea73cf8a28186a3f79cb036de62b71da Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 20 May 2020 13:29:31 +0200 Subject: [PATCH] Fixed allow_url_fopen with Mpdf --- .../vendor/mpdf/mpdf/src/Image/ImageProcessor.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pandora_console/vendor/mpdf/mpdf/src/Image/ImageProcessor.php b/pandora_console/vendor/mpdf/mpdf/src/Image/ImageProcessor.php index 81f23d625c..77f9a83d50 100644 --- a/pandora_console/vendor/mpdf/mpdf/src/Image/ImageProcessor.php +++ b/pandora_console/vendor/mpdf/mpdf/src/Image/ImageProcessor.php @@ -133,6 +133,7 @@ class ImageProcessor implements \Psr\Log\LoggerAwareInterface public function getImage(&$file, $firsttime = true, $allowvector = true, $orig_srcpath = false, $interpolation = false) { + global $config; // mPDF 6 // firsttime i.e. whether to add to this->images - use false when calling iteratively // Image Data passed directly as var:varname @@ -214,6 +215,20 @@ class ImageProcessor implements \Psr\Log\LoggerAwareInterface $type = $this->guesser->guess($data); } } + + if ((!$data || !$type) && !ini_get('allow_url_fopen') && preg_match('/data:image.*;base64/', $file)) { + $base_to_php = explode(',', $file); + $img_base64 = base64_decode($base_to_php[1]); + $filepath = $config['attachment_store']."/downloads/".uniqid().".jpg"; + $result = file_put_contents($filepath, $img_base64); + if ($result !== false) { + $data = file_get_contents($filepath); + if ($data) { + $type = $this->guesser->guess($data); + } + unlink($filepath); + } + } } if (!$data) {