diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index b45f6f895b3..1b421224761 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -7099,6 +7099,10 @@ function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml = false)
*/
function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom = 'UTF-8', $removelasteolbr = 1)
{
+ if (is_null($stringtoencode)) {
+ return '';
+ }
+
$newstring = $stringtoencode;
if (dol_textishtml($stringtoencode)) { // Check if text is already HTML or not
$newstring = preg_replace('/
/i', '
', $newstring); // Replace "
" by "
". It's same and avoid pb with FPDF.
@@ -7293,6 +7297,10 @@ function dol_nboflines_bis($text, $maxlinesize = 0, $charset = 'UTF-8')
*/
function dol_textishtml($msg, $option = 0)
{
+ if (is_null($msg)) {
+ return false;
+ }
+
if ($option == 1) {
if (preg_match('/