summaryrefslogtreecommitdiff
path: root/modules/user.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/user.module')
-rw-r--r--modules/user.module7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/user.module b/modules/user.module
index cb170f579..6cb02d04e 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));
}
}