public function callback($match)
{
$href = $orig_href = $match[0];
if (strpos($match[2], ':') === false) {
$href = 'http://' . $href;
}
if ($this->_params['callback']) {
$href = call_user_func($this->_params['callback'], $href);
}
$href = htmlspecialchars($href);
$class = $this->_params['class'];
if (!empty($class)) {
$class = ' class="' . $class . '"';
}
$target = $this->_params['target'];
if (!empty($target)) {
$target = ' target="' . $target . '"';
}
$decoded = $orig_href;
try {
if (strlen($host = $this->_parseurl($orig_href, PHP_URL_HOST))) {
$decoded = substr_replace($orig_href, Horde_Idna::decode($host), strpos($orig_href, $host), strlen($host));
}
} catch (Horde_Idna_Exception $e) {
} catch (InvalidArgumentException $e) {
}
$replacement = '<a href="' . $href . '"' . ($this->_params['nofollow'] ? ' rel="nofollow"' : '') . $target . $class . '>' . htmlspecialchars($decoded) . '</a>';
if (!empty($this->_params['noprefetch'])) {
$replacement = '<meta http-equiv="x-dns-prefetch-control" value="off" />' . $replacement . '<meta http-equiv="x-dns-prefetch-control" value="on" />';
}
if ($this->_params['encode']) {
$replacement = chr(0) . chr(0) . chr(0) . base64_encode($replacement) . chr(0) . chr(0) . chr(0);
}
return $replacement;
}