From 948030c5f0a7ed994d9c6cbc126c6119e701dba9 Mon Sep 17 00:00:00 2001 From: Bob van de Vijver Date: Wed, 20 Mar 2024 10:11:52 +0100 Subject: [PATCH] Add empty input checks to fix deprecations --- src/Helper/Parser.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Helper/Parser.php b/src/Helper/Parser.php index 30b94d8..58d5c54 100644 --- a/src/Helper/Parser.php +++ b/src/Helper/Parser.php @@ -74,6 +74,9 @@ public function __construct() { * @param bool $removeGreek If set, any greek character will be replaced by their LaTeX math equivalent (default false) */ public function parseText(?string $text, bool $checkTable = true, bool $removeLatex = false, bool $parseNewLines = false, bool $removeGreek = false): string { + if ($text === NULL || $text === '') { + return ''; + } // Try to replace HTML entities preg_match_all('/&[a-zA-Z]+;/iu', $text, $matches); @@ -228,6 +231,10 @@ public function parseText(?string $text, bool $checkTable = true, bool $removeLa * Parse the html input and create latex code of it */ public static function parseHtml(?string $text): ?string { + if ($text === NULL || $text === '') { + // BC compatible return value + return "\n\n"; + } // Replace NO-BREAK-SPACE with normal space $text = str_replace("\xc2\xa0", ' ', $text);