/** * Perform formatting against a string for the url tag. * * @param Nbbc $bbcode Instance of Nbbc doing the parsing. * @param int $action Value of one of NBBC's defined constants. Typically, this will be BBCODE_CHECK. * @param string $name Name of the tag. * @param string $default Value of the _default parameter, from the $params array. * @param array $params A standard set parameters related to the tag. * @param string $content Value between the open and close tags, if any. * @return bool|string Formatted value. */ function doURL($bbcode, $action, $name, $default, $params, $content) { if ($action == Nbbc::BBCODE_CHECK) { return true; } $url = is_string($default) ? $default : $bbcode->unHtmlEncode(strip_tags($content)); if ($bbcode->isValidURL($url)) { if ($bbcode->getDebug()) { print "ISVALIDURL<br />"; } if ($bbcode->getUrlTargetable() !== false && isset($params['target'])) { $target = " target=\"" . htmlspecialchars($params['target']) . "\""; } else { $target = ""; } if ($bbcode->getURLTarget() !== false) { if (!($bbcode->getUrlTargetable() == 'override' && isset($params['target']))) { $target = " target=\"" . htmlspecialchars($bbcode->getUrlTarget()) . "\""; } } $encodedUrl = htmlspecialchars($url); return "<a href=\"{$encodedUrl}\" rel=\"nofollow\" class=\"bbcode_url\"{$target}\">{$content}</a>"; } else { return htmlspecialchars($params['_tag']) . $content . htmlspecialchars($params['_endtag']); } }