public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Sterz <s.sterz@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH widget-toolkit] fix: toolkit: make email regex pattern match pve-common
Date: Wed,  7 Sep 2022 11:37:40 +0200	[thread overview]
Message-ID: <20220907093740.172217-1-s.sterz@proxmox.com> (raw)

`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>
---
note that there are many many regex patterns that could be used
(e.g.: [1]). im partial to w3c's approach [2], mainly because it's
likely to be widely used, while being fairly simple and compatible
with perl and javascript.

[1]: https://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
[2]: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address

 src/Toolkit.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Toolkit.js b/src/Toolkit.js
index ad64f89..c730374 100644
--- a/src/Toolkit.js
+++ b/src/Toolkit.js
@@ -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",
 
-- 
2.30.2





             reply	other threads:[~2022-09-07  9:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-07  9:37 Stefan Sterz [this message]
2022-09-12 15:15 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220907093740.172217-1-s.sterz@proxmox.com \
    --to=s.sterz@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal