diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0f81c0b1692..393755f39d2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7638,8 +7638,12 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = ' // like '

Foo

bar

' that wrongly ends up, without the trick, with '

Foo

bar

' // like 'abc' that wrongly ends up, without the trick, with '

abc

' - $out = '
'.$out.'
'; - $dom->loadHTML($out, LIBXML_HTML_NODEFDTD|LIBXML_ERR_NONE|LIBXML_HTML_NOIMPLIED|LIBXML_NONET|LIBXML_NOWARNING|LIBXML_NOXMLDECL); + if (dol_textishtml($out)) { + $out = '
'.$out.'
'; + } else { + $out = '
'.dol_nl2br($out).'
'; + } + $dom->loadHTML($out, LIBXML_HTML_NODEFDTD | LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOXMLDECL); $out = trim($dom->saveHTML()); // Remove the trick added to solve pb with text without parent tag