3 require_once 'HTMLPurifier/AttrDef/URI/Email.php';
6 * Primitive email validation class based on the regexp found at
7 * http://www.regular-expressions.info/email.html
9 class HTMLPurifier_AttrDef_URI_Email_SimpleCheck
extends HTMLPurifier_AttrDef_URI_Email
12 function validate($string, $config, &$context) {
13 // no support for named mailboxes i.e. "Bob <bob@example.com>"
14 // that needs more percent encoding to be done
15 if ($string == '') return false;
16 $string = trim($string);
17 $result = preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $string);
18 return $result ?
$string : false;