From 49c34d6949631572504e0adf02aec6775f0c8832 Mon Sep 17 00:00:00 2001 From: pezcurrel Date: Thu, 22 Aug 2024 11:51:42 +0200 Subject: [PATCH] Fixed a flaw in the regex preventing URLs at the very end of a string to be changed into links --- web/lib/text2html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/lib/text2html.php b/web/lib/text2html.php index 6bea204..25474be 100644 --- a/web/lib/text2html.php +++ b/web/lib/text2html.php @@ -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)#','$1$2',$text); + $text=preg_replace('#(https?://.+?)(\n|\s|$|\W\s|\W\n|\W$)#','$1$2',$text); $text=nl2br($text); return $text; }