This commit is contained in:
pezcurrel 2024-08-22 13:47:22 +02:00
parent 4542b4a80a
commit 04c8a7d66f

View file

@ -3,8 +3,8 @@
function text2html($text,$ifnoe) {
if (is_null($text) || preg_match('#^\s*$#',$text)===1)
return $ifnoe;
$text=htmlspecialchars($text,ENT_QUOTES|ENT_HTML5,'UTF-8');
$text=preg_replace('#(https?://.+?)(\n|\s|$|\W\s|\W\n|\W$)#','<a href="$1" target="_blank">$1</a>$2',$text);
$text=preg_replace(['#<#','#>#'],['&lt;','&gt;'],$text);
$text=preg_replace('#(https?://.+?)(\s|$|\W\s|\W$)#m','<a href="$1" target="_blank">$1</a>$2',$text);
$text=nl2br($text);
return $text;
}