Fixed a flaw in the regex preventing URLs at the very end of a string to be changed into links
This commit is contained in:
parent
40ceb04d2e
commit
49c34d6949
1 changed files with 1 additions and 1 deletions
|
@ -4,7 +4,7 @@ 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)#','<a href="$1" target="_blank">$1</a>$2',$text);
|
||||
$text=preg_replace('#(https?://.+?)(\n|\s|$|\W\s|\W\n|\W$)#','<a href="$1" target="_blank">$1</a>$2',$text);
|
||||
$text=nl2br($text);
|
||||
return $text;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue