Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / lib / htmlpurifier / HTMLPurifier / AttrDef / URI / Email / SimpleCheck.php
blobe35b1b4b28d77f339ae8e4dbfb696606b19ae0bd
1 <?php
3 require_once 'HTMLPurifier/AttrDef/URI/Email.php';
5 /**
6 * Primitive email validation class based on the regexp found at
7 * http://www.regular-expressions.info/email.html
8 */
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;