Fix URL encoding issues

Resolves #235.
This commit is contained in:
Trevor Slocum 2021-07-08 19:45:10 -07:00
parent 013270c532
commit 340b66fe1b

View file

@ -95,12 +95,13 @@ function _makeLinksClickable($matches) {
if (!isset($matches[1])) {
return '';
}
$url = htmlentities($matches[1], ENT_QUOTES);
return '<a href="' . $url . '" target="_blank">' . $url . '</a>';
$url = str_replace('&amp;', '&', htmlspecialchars($matches[1], ENT_QUOTES));
$text = htmlentities($matches[1], ENT_QUOTES);
return '<a href="' . $url . '" target="_blank">' . $text . '</a>';
}
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 href\=\"(.*)\)"\ target\=\"\_blank\">(.*)\)\<\/a>/i', '(<a href="$1" target="_blank">$2</a>)', $text);
$text = preg_replace('/\<a href\=\"(.*)\."\ target\=\"\_blank\">(.*)\.\<\/a>/i', '<a href="$1" target="_blank">$2</a>.', $text);
$text = preg_replace('/\<a href\=\"(.*)\,"\ target\=\"\_blank\">(.*)\,\<\/a>/i', '<a href="$1" target="_blank">$2</a>,', $text);