From 491a1373e07ac356eac8f0c40f7841416ef5c2a4 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 19 Jan 2018 21:39:57 -0500 Subject: [PATCH] Fix autolink regular expression to include accents --- include/bbcode.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index a6ffc39c1..ffc2387c3 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -968,11 +968,12 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa // if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text if (!$forplaintext) { - // Autolink feature + // Autolink feature (thanks to http://code.seebz.net/p/autolink-php/) + $autolink_regex = "`([^\]\=\"']|^)(https?\://[^\s<]+[^\s<\.\)])`ism"; if ($simplehtml != 7) { - $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@]+)/ism", '$1$2', $Text); + $Text = preg_replace($autolink_regex, '$1$2', $Text); } else { - $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@]+)/ism", '$1[url]$2[/url]', $Text); + $Text = preg_replace($autolink_regex, '$1[url]$2[/url]', $Text); $Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism", 'bb_style_url', $Text); $Text = preg_replace_callback("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", 'bb_style_url', $Text);