From e2d032dc15c6f0b926173cc32b38e449426b93a6 Mon Sep 17 00:00:00 2001 From: Damien Grandi Date: Wed, 6 Nov 2019 12:09:51 +0100 Subject: [PATCH] Bugfix for DataUrl containing newlines inside data Remove the newlines before doing a Regex check inside the decodeDataUrl method in the same way that is the isBase64 method doing. --- src/Intervention/Image/AbstractDecoder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Intervention/Image/AbstractDecoder.php b/src/Intervention/Image/AbstractDecoder.php index de770c328..397c206ff 100644 --- a/src/Intervention/Image/AbstractDecoder.php +++ b/src/Intervention/Image/AbstractDecoder.php @@ -290,7 +290,7 @@ private function decodeDataUrl($data_url) } $pattern = "/^data:(?:image\/[a-zA-Z\-\.]+)(?:charset=\".+\")?;base64,(?P.+)$/"; - preg_match($pattern, $data_url, $matches); + preg_match($pattern, str_replace(["\n", "\r"], '', $data_url), $matches); if (is_array($matches) && array_key_exists('data', $matches)) { return base64_decode($matches['data']);