From cc20b29300d4d35d40b543f957b5ca42e3f4c312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Bernigaud?= <come.bernigaud@laposte.net> Date: Thu, 24 Jan 2013 14:13:13 +0100 Subject: [PATCH] Fixes: #1859 Changed email validation system --- include/class_tests.inc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/class_tests.inc b/include/class_tests.inc index bbfd623ef..acf2aaf3e 100644 --- a/include/class_tests.inc +++ b/include/class_tests.inc @@ -271,18 +271,18 @@ class tests { * * \param boolean $template FALSE */ - public static function is_email($address, $template= FALSE) + public static function is_email($address, $deprecated = FALSE) { - if ($address == ""){ - return (TRUE); + if ($address == "") { + return TRUE; } - if ($template){ - return preg_match ("/^[._a-z0-9%\+-]+@[_a-z0-9-]+(\.[a-z0-9-]+)(\.[a-z0-9-]+)*$/i", - $address); - } else { - return preg_match ("/^[._a-z0-9\+-]+@[_a-z0-9-]+(\.[a-z0-9i-]+)(\.[a-z0-9-]+)*$/i", - $address); + if (filter_var($address, FILTER_VALIDATE_EMAIL) !== FALSE) { + return TRUE; + } elseif (filter_var($address.'.com', FILTER_VALIDATE_EMAIL) !== FALSE) { + /* this is to allow addresses like example@localhost, which are refused by some PHP version */ + return TRUE; } + return FALSE; } -- GitLab