the regexes used are bloated, but a quickie fix would be:

(added to not break the flow)
PHP Code
if ($this->allow_magic_urls) {
	for ($i = 0; $i < 3; $i++) {
		$body = preg_replace('#(\n|\r|\]|^|\s|\(|&lt;)([a-zA-Z0-9]+?)://(([a-zA-Z0-9\.\+\,\-\%\_\?=\:\@\#/&\$]|&amp;)+)(&gt;|&lt;|\n|\r|$|,(\s|$)|\?(\s|$)|\)|\s|\.(\s|$))#ie', '\'$1\'.$this->handle_url(\'$2://$3\').\'$5\'', $body);
	}
	$body = preg_replace('#(\n|\r|\]|^|\s|&lt;|\()www\.(([a-zA-Z0-9\.\+\-\:\,\%\_\@\?&/\#=\$]|&amp;)+)($|&gt;|\)|,(\s|$)|\?(\s|$)|\)(\s|$)|\s|\.(\s|$))#ie', '\'$1\'.$this->handle_url(\'http://www.$2\',\'www.$2\').\'$4\'', $body);
}
 

search for "if ($this->allow_magic_urls) {"

you'll see the current code there..

if i have time, i can shorten up that code to be cleaner.. i brute force added parsing the '$' and ':' in there.. there is too much escaping than needed, but it works..