function spamspan_convertmailto in SpamSpan filter 5
2 calls to spamspan_convertmailto()
- Main::testMailto in test/spamspan_test.inc
- spamspan_filter in ./spamspan.module
- Implementation of hook_filter().
File
- ./spamspan.module, line 166
- This module implements the spamspan technique
(http://www.spamspan.com ) for hiding email addresses from spambots.
If javascript is disabled on the client-side, addresses appear as
example [at] example [dot] com.
Code
function spamspan_convertmailto($string = '') {
define("REGEX", "!<a\\s+ # opening <a and spaces\n (?:(?:\\w+\\s*=\\s*)(?:\\w+|\"[^\"]*\"|'[^']*'))*? # any attributes\n \\s* # whitespace\n href\\s*=\\s*(['\"])mailto:(.+?)\\1 # the href attribute, capturing the value\n (?:(?:\\s+\\w+\\s*=\\s*)(?:\\w+|\"[^\"]*\"|'[^']*'))*? # any more attributes\n > # end of the first tag\n .*? # tag contents. NB this will not work properly if there\n # is a nested <a>, but this is not valid xhtml anyway\n </a> # closing tag\n !ix");
return preg_replace(REGEX, "\\2", $string);
}