]> git.proxmox.com Git - pve-common.git/commitdiff
fix #2111: regex match for email addresses
authorOguz Bektas <o.bektas@proxmox.com>
Thu, 28 Feb 2019 14:00:04 +0000 (15:00 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 1 Mar 2019 09:36:50 +0000 (10:36 +0100)
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 <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Dominik Csapak <d.csapak@proxmox.com>
src/PVE/JSONSchema.pm

index 36fa994eb7e6d4bddeb2600585a085cdc7c7ba70..1e3bf5d48c17066fe348954e66b48dbb5a98e4c0 100644 (file)
@@ -356,8 +356,7 @@ register_format('email', \&pve_verify_email);
 sub pve_verify_email {
     my ($email, $noerr) = @_;
 
 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";
     }
           return undef if $noerr;
           die "value does not look like a valid email address\n";
     }