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--) {