[pve-devel] [PATCH common] fix #2111: regex match email address without tld

Oguz Bektas o.bektas at proxmox.com
Fri Feb 22 15:10:13 CET 2019


for matching root at localhost or similar.

expression taken from emailregex.com for html5.

Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
 src/PVE/JSONSchema.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 36fa994..b5f9621 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -356,8 +356,8 @@ 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}$/) {
+    # html5 email regex
+    if ($email !~ /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/) {
 	   return undef if $noerr;
 	   die "value does not look like a valid email address\n";
     }
-- 
2.11.0





More information about the pve-devel mailing list