From 83b0bef3a891e2304f9fe4cc832d3e5705b6fe31 Mon Sep 17 00:00:00 2001 From: neopheus Date: Mon, 12 Sep 2022 12:56:45 +0200 Subject: [PATCH 1/3] Fix #2290 --- src/PhpWord/TemplateProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 664d46887e..14c95b18d6 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -257,7 +257,7 @@ protected static function ensureMacroCompleted($macro) */ protected static function ensureUtf8Encoded($subject) { - if (!Text::isUTF8($subject)) { + if (!Text::isUTF8($subject) && !is_null($subject)) { $subject = utf8_encode($subject); } From 077175efbef67fbaef1e3145b7d544e1b2c17893 Mon Sep 17 00:00:00 2001 From: neopheus Date: Mon, 12 Sep 2022 13:48:13 +0200 Subject: [PATCH 2/3] Fix : htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated --- src/PhpWord/Escaper/Xml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Escaper/Xml.php b/src/PhpWord/Escaper/Xml.php index a769c5e189..073e297d2c 100644 --- a/src/PhpWord/Escaper/Xml.php +++ b/src/PhpWord/Escaper/Xml.php @@ -27,6 +27,6 @@ class Xml extends AbstractEscaper protected function escapeSingleValue($input) { // todo: omit encoding parameter after migration onto PHP 5.4 - return htmlspecialchars($input, ENT_QUOTES, 'UTF-8'); + return (!is_null($input)) ? htmlspecialchars($input, ENT_QUOTES, 'UTF-8') : null; } } From fa84160f7f55a6e28c24cb5b8769518383c09c47 Mon Sep 17 00:00:00 2001 From: neopheus Date: Mon, 12 Sep 2022 13:59:21 +0200 Subject: [PATCH 3/3] str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated" --- src/PhpWord/Escaper/Xml.php | 2 +- src/PhpWord/TemplateProcessor.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Escaper/Xml.php b/src/PhpWord/Escaper/Xml.php index 073e297d2c..316ee85e63 100644 --- a/src/PhpWord/Escaper/Xml.php +++ b/src/PhpWord/Escaper/Xml.php @@ -27,6 +27,6 @@ class Xml extends AbstractEscaper protected function escapeSingleValue($input) { // todo: omit encoding parameter after migration onto PHP 5.4 - return (!is_null($input)) ? htmlspecialchars($input, ENT_QUOTES, 'UTF-8') : null; + return (!is_null($input)) ? htmlspecialchars($input, ENT_QUOTES, 'UTF-8') : ''; } } diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 14c95b18d6..09f5461995 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -261,7 +261,7 @@ protected static function ensureUtf8Encoded($subject) $subject = utf8_encode($subject); } - return $subject; + return (!is_null($subject)) ? $subject : ''; } /**