From a76151351e0e00da6b5e7f81fdd009cb44e7eabe Mon Sep 17 00:00:00 2001 From: Kjartan Mannes Date: Sat, 15 Feb 2003 20:52:28 +0000 Subject: - Modifying user_validate_mail() to accept more e-mail addresses. --- modules/user/user.module | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'modules/user/user.module') diff --git a/modules/user/user.module b/modules/user/user.module index cb170f579..6cb02d04e 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -187,7 +187,12 @@ function user_validate_mail($mail) { ** allowed. */ - if ($mail && !eregi("^[0-9a-z_\.-]+@(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2,})$", $mail)) { + $user = '[a-zA-Z0-9_\-\.]+'; + $domain = '(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9]\.?)+'; + $ipv4 = '[0-9]{1,3}(\.[0-9]{1,3}){3}'; + $ipv6 = '[0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7}'; + + if ($mail && !preg_match("/^$user@($domain|(\[($ipv4|$ipv6)\]))$/", $mail)) { return t("The e-mail address '%mail' is not valid.", array("%mail" => $mail)); } } -- cgit v1.2.3