From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 7/7] proxinstall: use email regex from HTML specification for validation
Date: Tue, 28 May 2024 10:13:48 +0200 [thread overview]
Message-ID: <20240528081359.832986-8-c.heiss@proxmox.com> (raw)
In-Reply-To: <20240528081359.832986-1-c.heiss@proxmox.com>
That regex should be a lot more accurate in what it allows - if it's
good enough for the HTML spec, it should be for us too.
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Proxmox/Makefile | 1 +
Proxmox/Sys.pm | 9 +++++++++
proxinstall | 3 ++-
3 files changed, 12 insertions(+), 1 deletion(-)
create mode 100644 Proxmox/Sys.pm
diff --git a/Proxmox/Makefile b/Proxmox/Makefile
index 9561d9b..6f9eea8 100644
--- a/Proxmox/Makefile
+++ b/Proxmox/Makefile
@@ -12,6 +12,7 @@ PERL_MODULES=\
Install/RunEnv.pm \
Install/StorageConfig.pm \
Log.pm \
+ Sys.pm \
Sys/Block.pm \
Sys/Command.pm \
Sys/File.pm \
diff --git a/Proxmox/Sys.pm b/Proxmox/Sys.pm
new file mode 100644
index 0000000..afc6780
--- /dev/null
+++ b/Proxmox/Sys.pm
@@ -0,0 +1,9 @@
+package Proxmox::Sys;
+
+use strict;
+use warnings;
+
+# The HTML specification actually gives a "blessed" regex for email addresses:
+# https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
+# Using that /should/ cover all possible cases that are encountered in the wild.
+our $EMAIL_RE = '^[a-zA-Z0-9.!#$%&\'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$';
diff --git a/proxinstall b/proxinstall
index a6a4cfb..79b0c76 100755
--- a/proxinstall
+++ b/proxinstall
@@ -33,6 +33,7 @@ my $iso_env = Proxmox::Install::ISOEnv::get();
use Proxmox::Install;
use Proxmox::Install::Config;
+use Proxmox::Sys;
use Proxmox::Sys::Block qw(get_cached_disks);
use Proxmox::Sys::Command qw(syscmd);
use Proxmox::Sys::File qw(file_read_all file_write_all);
@@ -733,7 +734,7 @@ sub create_password_view {
}
my $t3 = $eme->get_text;
- if ($t3 !~ m/^[\w\+\-\~]+(\.[\w\+\-\~]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*$/) {
+ if ($t3 !~ m/$Proxmox::Sys::EMAIL_RE/) {
Proxmox::UI::message("Email does not look like a valid address (user\@domain.tld)");
$eme->grab_focus();
return;
--
2.44.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2024-05-28 8:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 8:13 [pve-devel] [PATCH installer 0/7] use email regex from HTML spec " Christoph Heiss
2024-05-28 8:13 ` [pve-devel] [PATCH installer 1/7] cargo: convert `anyhow` to workspace dependency Christoph Heiss
2024-05-28 8:13 ` [pve-devel] [PATCH installer 2/7] tui: fix new clippy lint Christoph Heiss
2024-05-28 8:13 ` [pve-devel] [PATCH installer 3/7] auto-installer: drop some unneeded `pub` modifiers Christoph Heiss
2024-05-28 8:13 ` [pve-devel] [PATCH installer 4/7] auto-installer: print full anyhow message on failure Christoph Heiss
2024-05-28 8:13 ` [pve-devel] [PATCH installer 5/7] tui: use email regex from HTML specification for validation Christoph Heiss
2024-05-28 8:13 ` [pve-devel] [PATCH installer 6/7] auto-installer: validate `global.mailto` answer option Christoph Heiss
2024-05-28 8:13 ` Christoph Heiss [this message]
2024-06-03 8:20 ` [pve-devel] [PATCH installer 0/7] use email regex from HTML spec for validation Max Carrara
2024-06-28 8:16 ` Christoph Heiss
2024-10-02 12:32 ` Christoph Heiss
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=20240528081359.832986-8-c.heiss@proxmox.com \
--to=c.heiss@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