/** * Format an [email] tag by producing an <a href="mailto:...">...</a> element. * * The e-mail address must be a valid address including at least a '@' and a valid domain * name or IPv4 or IPv6 address after the '@'. * * @param BBCode $bbcode The {@link BBCode} object doing the parsing. * @param int $action The current action being performed on the tag. * @param string $name The name of the tag. * @param string $default The default value passed to the tag in the form: `[tag=default]`. * @param array $params All of the parameters passed to the tag. * @param string $content The content of the tag. Only available when {@link $action} is **BBCODE_OUTPUT**. * @return string Returns the email link HTML. */ public function doEmail(BBCode $bbcode, $action, $name, $default, $params, $content) { // We can't check this with BBCODE_CHECK because we may have no URL // before the content has been processed. if ($action == BBCode::BBCODE_CHECK) { return true; } $email = is_string($default) ? $default : $bbcode->unHTMLEncode(strip_tags($content)); if ($bbcode->isValidEmail($email)) { return $bbcode->fillTemplate($bbcode->getEmailTemplate(), array("email" => $email, "content" => $content)); } else { return htmlspecialchars($params['_tag']) . $content . htmlspecialchars($params['_endtag']); } }