From d297dfe60e9534f49d627d46d43c1ad7f3f60b1f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Mar 2024 17:32:09 +0100 Subject: [PATCH] Fix warning --- htdocs/core/lib/functions.lib.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d150e866f0262..3403a95d269b3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7648,7 +7648,11 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes // Warning: loadHTML does not support HTML5 on old libxml versions. $dom = new DOMDocument('', 'UTF-8'); + // If $stringtoclean is wrong, it will generates warnings. So we disable warnings and restore them later. + $savwarning = error_reporting(); + error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE); $dom->loadHTML($stringtoclean, LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOXMLDECL); + error_reporting($savwarning); if ($dom instanceof DOMDocument) { for ($els = $dom->getElementsByTagname('*'), $i = $els->length - 1; $i >= 0; $i--) {