Cleanup creating links and add protocols
This commit is contained in:
parent
50993b3ab7
commit
3cbdc0d875
|
@ -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('/(\<|\>);/', '', $word);
|
||||
$nlink = rtrim($nlink, '.');
|
||||
if(preg_match('/(https?|ftp|news|gopher|telnet)\:\/\/[^\",]+/i', $word)) {
|
||||
$nlink = trim($word, '().');
|
||||
$nlink = preg_replace('/(\<|\>|\ );/', '', $nlink);
|
||||
$nword = '<a '.$target.' href="'.$nlink.'">'.$word.'</a>';
|
||||
if($nword!=$word) {
|
||||
if($nword!=$word && substr($nlink, strlen($nlink) - 3) != "://") {
|
||||
$word=$nword;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue