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

Emmanuel Kasper e.kasper at proxmox.com
Wed Sep 16 17:08:30 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
patch to update the server side validation will follow.

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       | 7 ++++++-
 www/manager/Utils.js         | 3 +++
 www/manager/dc/OptionView.js | 2 +-
 www/manager/dc/UserEdit.js   | 2 +-
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/www/manager/Toolkit.js b/www/manager/Toolkit.js
index 65be809..6f82e59 100644
--- a/www/manager/Toolkit.js
+++ b/www/manager/Toolkit.js
@@ -83,7 +83,12 @@ 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'),
+
+    pveMail: function(v) {
+        return pveMailAddress.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/Utils.js b/www/manager/Utils.js
index 0e2e8a2..1b6e063 100644
--- a/www/manager/Utils.js
+++ b/www/manager/Utils.js
@@ -48,6 +48,9 @@ var IP6_bracket_match = new RegExp("^\\[(" + IPV6_REGEXP + ")\\]");
 
 var IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$");
 
+// workaround for https://www.sencha.com/forum/showthread.php?302150
+var pveMailAddress = /^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,63}$/;
+
 Ext.define('PVE.Utils', { statics: {
 
     // this class only contains static functions
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