From 340b66fe1b9be368db7b92c8bfd2447444678c22 Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Thu, 8 Jul 2021 19:45:10 -0700 Subject: [PATCH] Fix URL encoding issues Resolves #235. --- inc/html.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/inc/html.php b/inc/html.php index dcf8332..a078c33 100644 --- a/inc/html.php +++ b/inc/html.php @@ -95,12 +95,13 @@ function _makeLinksClickable($matches) { if (!isset($matches[1])) { return ''; } - $url = htmlentities($matches[1], ENT_QUOTES); - return '' . $url . ''; + $url = str_replace('&', '&', htmlspecialchars($matches[1], ENT_QUOTES)); + $text = htmlentities($matches[1], ENT_QUOTES); + return '' . $text . ''; } function makeLinksClickable($text) { - $text = preg_replace_callback('!(((f|ht)tp(s)?://)[-a-zA-Zа-яА-Я()0-9@:%\!_+.,~#?&;\'/=]+)!i', '_makeLinksClickable', $text); + $text = preg_replace_callback('!(((f|ht)tp(s)?://)[-a-zA-Zа-яА-Я()0-9@%\!_+.,~#?&;:|\'/=]+)!i', '_makeLinksClickable', $text); $text = preg_replace('/\(\(.*)\)\<\/a>/i', '($2)', $text); $text = preg_replace('/\(.*)\.\<\/a>/i', '$2.', $text); $text = preg_replace('/\(.*)\,\<\/a>/i', '$2,', $text);