From cbc2d9eab7e0d6f6a2d45a613d870e2573bc87b8 Mon Sep 17 00:00:00 2001 From: Pawel Skotnicki Date: Thu, 9 Nov 2023 14:35:25 +0100 Subject: [PATCH] Ignore invalid _exel-styles --- lib/HtmlPhpExcel/HtmlPhpExcel.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/HtmlPhpExcel/HtmlPhpExcel.php b/lib/HtmlPhpExcel/HtmlPhpExcel.php index aa36a4f..11bebc4 100644 --- a/lib/HtmlPhpExcel/HtmlPhpExcel.php +++ b/lib/HtmlPhpExcel/HtmlPhpExcel.php @@ -191,9 +191,9 @@ private function getStyles(HtmlPhpExcelElement\Element $documentElement): array $styles = []; if ($attributeStyles = $documentElement->getAttribute('_excel-styles')) { if (!is_array($attributeStyles)) { - $decodedJson = json_decode($attributeStyles, true, 512, JSON_THROW_ON_ERROR); - if (null !== $decodedJson) { - $attributeStyles = $decodedJson; + try { + $attributeStyles = json_decode($attributeStyles, true, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException) { } } }