fix email validate

This commit is contained in:
joyqi 2023-05-15 19:55:36 +08:00
parent c9de1b3b01
commit 7a41f0d013

View File

@ -96,7 +96,8 @@ class Validate
*/
public static function email(string $str): bool
{
return (bool) preg_match("/^[_a-z0-9-\.]+@([-a-z0-9]+\.)+[a-z]{2,}$/i", $str);
$email = filter_var($str, FILTER_SANITIZE_EMAIL);
return filter_var($str, FILTER_VALIDATE_EMAIL) && ($email === $str);
}
/**