From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id A579F1FF15C for ; Wed, 2 Oct 2024 14:29:37 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 54004E7CC; Wed, 2 Oct 2024 14:29:47 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Wed, 2 Oct 2024 14:27:28 +0200 Message-ID: <20241002122933.628461-8-c.heiss@proxmox.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241002122933.628461-1-c.heiss@proxmox.com> References: <20241002122933.628461-1-c.heiss@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.120 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH installer v2 7/7] proxinstall: use email regex from HTML specification for validation X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" 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 --- Changes v1 -> v2: * no changes 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 035626b..edcabc1 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 12f3eaa..8b7f1c0 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.46.0 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel