Browse Source

Fix URL encoding issues

Resolves #235.
sqlitefix
Trevor Slocum 1 year ago
parent
commit
340b66fe1b
  1. 7
      inc/html.php

7
inc/html.php

@ -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);

Loading…
Cancel
Save