Cleanup creating links and add protocols

This commit is contained in:
Retro_Guy 2021-06-16 09:04:22 +00:00
parent 50993b3ab7
commit 3cbdc0d875
1 changed files with 4 additions and 4 deletions

View File

@ -883,11 +883,11 @@ function html_parse($text) {
$n=count($words);
for($i=0; $i<$n; $i++) {
$word=$words[$i];
if(preg_match('/https?\:\/\/[^\",]+/i', $word)) {
$nlink = preg_replace('/(\&lt|\&gt);/', '', $word);
$nlink = rtrim($nlink, '.');
if(preg_match('/(https?|ftp|news|gopher|telnet)\:\/\/[^\",]+/i', $word)) {
$nlink = trim($word, '().');
$nlink = preg_replace('/(\&lt|\&gt|\&nbsp);/', '', $nlink);
$nword = '<a '.$target.' href="'.$nlink.'">'.$word.'</a>';
if($nword!=$word) {
if($nword!=$word && substr($nlink, strlen($nlink) - 3) != "://") {
$word=$nword;
}
}