From 8050285f86443150bbe7f526cd4d5d12449b5c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20H=C3=A4rtl?= Date: Tue, 17 Oct 2023 15:00:30 +0200 Subject: [PATCH] Issue #315 Fix htmlspecialchars() warning for null values --- src/XfdfFile.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/XfdfFile.php b/src/XfdfFile.php index 7204f98..c1be2d9 100644 --- a/src/XfdfFile.php +++ b/src/XfdfFile.php @@ -218,11 +218,14 @@ protected function writeFields($fp, $fields) } /** - * @param string $value the value to encode - * @return string the value correctly encoded for use in a XML document + * @param string|null $value the value to encode + * @return string|null the value correctly encoded for use in a XML document */ protected function xmlEncode($value) { + if ($value === null) { + return null; + } return defined('ENT_XML1') ? htmlspecialchars($value, ENT_XML1, 'UTF-8') : htmlspecialchars($value);