[pve-devel] r5576 - in pve-common/trunk/data: . PVE

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Feb 22 06:20:39 CET 2011


Author: dietmar
Date: 2011-02-22 06:20:38 +0100 (Tue, 22 Feb 2011)
New Revision: 5576

Modified:
   pve-common/trunk/data/ChangeLog
   pve-common/trunk/data/PVE/JSONSchema.pm
Log:
verify email address


Modified: pve-common/trunk/data/ChangeLog
===================================================================
--- pve-common/trunk/data/ChangeLog	2011-02-22 05:05:36 UTC (rev 5575)
+++ pve-common/trunk/data/ChangeLog	2011-02-22 05:20:38 UTC (rev 5576)
@@ -1,3 +1,7 @@
+2011-02-22  Proxmox Support Team  <support at proxmox.com>
+
+	* PVE/JSONSchema.pm (pve_verify_email): verify email address
+
 2011-02-16  Proxmox Support Team  <support at proxmox.com>
 
 	* PVE/RPCEnvironment.pm: moved to pve-access-control 

Modified: pve-common/trunk/data/PVE/JSONSchema.pm
===================================================================
--- pve-common/trunk/data/PVE/JSONSchema.pm	2011-02-22 05:05:36 UTC (rev 5575)
+++ pve-common/trunk/data/PVE/JSONSchema.pm	2011-02-22 05:20:38 UTC (rev 5576)
@@ -120,6 +120,18 @@
     return $ipv4;
 }
 
+register_format('email', \&pve_verify_email);
+sub pve_verify_email {
+    my ($email, $noerr) = @_;
+
+    # we use same regex as extjs Ext.form.VTypes.email
+    if ($email !~ /^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,6}$/) {
+	   return undef if $noerr;
+	   die "value does not look like a valid email address\n";
+    }
+    return $email;
+}
+
 sub check_format {
     my ($format, $value) = @_;
 




More information about the pve-devel mailing list