Sure it's not foolproof, a very long domain name could still screw you over but you could always pick a few other letters to be replaced using the soft-dot-method employed here.
Code: Select all
<?php
function create_soft_dots($input)
{
$output = str_replace(".",".<span style="display: none"> </span>",$input);
return $output;
}
$search = array("'(([^=])((https?://(([a-z0-9_-]{1,}\.[a-z0-9_\.-]+)/?)?[a-z0-9_/\+&#=\.-]*)))\b'i"
,"'\[url link=(((https?://([a-z0-9_-]{1,}\.[a-z0-9_\.-]+)/?)?[a-z0-9_/=\?&#;\.\+-]*))\]([a-z0-9&#;_\?= ''"\.@-]+)\[/url\]'ei"
);
$replace = array("\\2[url link=\\3]\\6[/url]"
,"'<a href="\\1"'.(("\\3")?' target="_blank"':'').'>'.create_soft_dots("\\5").'</a>'"
);
$html = preg_replace($search, $replace, $plainText);
?>I'd also already stripped out html and replaced all special characters with their html encoded version before reaching this line.