From: Oguz Bektas Date: Thu, 28 Feb 2019 14:00:04 +0000 (+0100) Subject: fix #2111: regex match for email addresses X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=4cd6dc0a987b95036a68bdfdef561241a595d4e9 fix #2111: regex match for email addresses now allows: * addresses without tld (f.e. user@localhost per bug) * remove limits for number of subdomains * allow +, -, ~ in local part * disallow double dots (.. .a. etc) and dots in the end (abc.@mail.com) Signed-off-by: Oguz Bektas Signed-off-by: Thomas Lamprecht Acked-by: Dominik Csapak --- diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm index 36fa994..1e3bf5d 100644 --- a/src/PVE/JSONSchema.pm +++ b/src/PVE/JSONSchema.pm @@ -356,8 +356,7 @@ register_format('email', \&pve_verify_email); sub pve_verify_email { my ($email, $noerr) = @_; - # we use same regex as in Utils.js - if ($email !~ /^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,63}$/) { + if ($email !~ /^[\w\+\-\~]+(\.[\w\+\-\~]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*$/) { return undef if $noerr; die "value does not look like a valid email address\n"; }