From a76151351e0e00da6b5e7f81fdd009cb44e7eabe Mon Sep 17 00:00:00 2001 From: Kjartan Mannes <kjartan@2.no-reply.drupal.org> Date: Sat, 15 Feb 2003 20:52:28 +0000 Subject: [PATCH] - Modifying user_validate_mail() to accept more e-mail addresses. --- modules/user.module | 7 ++++++- modules/user/user.module | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/user.module b/modules/user.module index cb170f579548..6cb02d04eb48 100644 --- a/modules/user.module +++ b/modules/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)); } } diff --git a/modules/user/user.module b/modules/user/user.module index cb170f579548..6cb02d04eb48 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)); } } -- GitLab