]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
fix: toolkit: make email regex pattern match pve-common
authorStefan Sterz <s.sterz@proxmox.com>
Wed, 7 Sep 2022 09:37:40 +0000 (11:37 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 12 Sep 2022 15:14:45 +0000 (17:14 +0200)
`proxmoxMail` used its own regex pattern to validate emails. that
meant certain email addresses were rejected by the front-end that
were accepted by the backend that uses the functionality from
`pve-common`. examples include the following:

- "user@host.test-tld"
- "user-@host.testtld"
- "user@host"

reported on the forum: https://forum.proxmox.com/threads/gui-bugulance-using-the-user-add-gui-interface.114743/

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
src/Toolkit.js

index ad64f89d47d1b049eb3c8eb11f4619ad17db3b80..c7303747d18fefe1f45b13528c943379c5008d56 100644 (file)
@@ -131,9 +131,9 @@ Ext.apply(Ext.form.field.VTypes, {
     },
     DnsNameOrWildcardText: gettext('This is not a valid DNS name'),
 
-    // workaround for https://www.sencha.com/forum/showthread.php?302150
+    // email regex used by pve-common
     proxmoxMail: function(v) {
-        return (/^(\w+)([-+.][\w]+)*@(\w[-\w]*\.){1,5}([A-Za-z]){2,63}$/).test(v);
+        return (/^[\w+-~]+(\.[\w+-~]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/).test(v);
     },
     proxmoxMailText: gettext('Example') + ": user@example.com",