[pve-devel] [PATCH v2 pve-manager] Allow email adresses with a top level domain of up to 63 characters

Emmanuel Kasper e.kasper at proxmox.com
Fri Sep 18 12:40:53 CEST 2015


This patch allows email adresses of the form john.public at company.hamburg
This fixes the bug: https://bugzilla.proxmox.com/show_bug.cgi?id=716

Note that this patch only deals will the client side validation, a
separate deals with the server side validation
(http://pve.proxmox.com/pipermail/pve-devel/2015-September/017246.html)

Implementation:
Just copied the original email regexp from ExtJS, and bumped the TLD length
from 6 to the max allowed by the corresponding RFC, ie 63 (https://tools.ietf.org/html/rfc1034)
---
 www/manager/Toolkit.js       | 8 +++++++-
 www/manager/dc/OptionView.js | 2 +-
 www/manager/dc/UserEdit.js   | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/www/manager/Toolkit.js b/www/manager/Toolkit.js
index 65be809..d38a82c 100644
--- a/www/manager/Toolkit.js
+++ b/www/manager/Toolkit.js
@@ -83,7 +83,13 @@ Ext.apply(Ext.form.field.VTypes, {
     DnsName: function(v) {
 	return (/^(([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)\.)*([A-Za-z0-9]([A-Za-z0-9\-]*[A-Za-z0-9])?)$/).test(v);
     },
-    DnsNameText: gettext('This is not a valid DNS name')
+    DnsNameText: gettext('This is not a valid DNS name'),
+
+    // workaround for https://www.sencha.com/forum/showthread.php?302150
+    pveMail: function(v) {
+        return (/^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,63}$/).test(v);
+    },
+    pveMailText: gettext('This field should be an e-mail address in the format "user at example.com"'),
 });
 
 // we dont want that a displayfield set the form dirty flag! 
diff --git a/www/manager/dc/OptionView.js b/www/manager/dc/OptionView.js
index 9e33e32..1a94be7 100644
--- a/www/manager/dc/OptionView.js
+++ b/www/manager/dc/OptionView.js
@@ -85,7 +85,7 @@ Ext.define('PVE.dc.EmailFromEdit', {
 	    items: {
 		xtype: 'pvetextfield',
 		name: 'email_from',
-		vtype: 'email',
+		vtype: 'pveMail',
 		emptyText: gettext('Send emails from root@$hostname'),
 		deleteEmpty: true,
 		value: '',
diff --git a/www/manager/dc/UserEdit.js b/www/manager/dc/UserEdit.js
index bb110b5..2ef8bce 100644
--- a/www/manager/dc/UserEdit.js
+++ b/www/manager/dc/UserEdit.js
@@ -117,7 +117,7 @@ Ext.define('PVE.dc.UserEdit', {
 		xtype: 'textfield',
 		name: 'email',
 		fieldLabel: gettext('E-Mail'),
-		vtype: 'email'
+		vtype: 'pveMail'
 	    }
 	];
 
-- 
2.1.4




More information about the pve-devel mailing list