File indexing completed on 2025-02-02 05:43:42

0001 <?php
0002 
0003 /**
0004  * Primitive email validation class based on the regexp found at
0005  * http://www.regular-expressions.info/email.html
0006  */
0007 class HTMLPurifier_AttrDef_URI_Email_SimpleCheck extends HTMLPurifier_AttrDef_URI_Email
0008 {
0009 
0010     /**
0011      * @param string $string
0012      * @param HTMLPurifier_Config $config
0013      * @param HTMLPurifier_Context $context
0014      * @return bool|string
0015      */
0016     public function validate($string, $config, $context)
0017     {
0018         // no support for named mailboxes i.e. "Bob <bob@example.com>"
0019         // that needs more percent encoding to be done
0020         if ($string == '') {
0021             return false;
0022         }
0023         $string = trim($string);
0024         $result = preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $string);
0025         return $result ? $string : false;
0026     }
0027 }
0028 
0029 // vim: et sw=4 sts=4