From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id E72F31FF13A for ; Wed, 27 May 2026 15:06:16 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4646C1C8AE; Wed, 27 May 2026 15:06:15 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH pve-installer 2/3] use email validation from installer-types Date: Wed, 27 May 2026 15:05:58 +0200 Message-ID: <20260527130611.2995147-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260527130611.2995147-1-d.csapak@proxmox.com> References: <20260527130611.2995147-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.101 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [main.rs,whatwg.org,utils.rs,options.rs] Message-ID-Hash: Z56G2PVTNPYYTCAG6QODRTXHJWJJICS4 X-Message-ID-Hash: Z56G2PVTNPYYTCAG6QODRTXHJWJJICS4 X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: was moved there so no need to have it here. Signed-off-by: Dominik Csapak --- proxmox-auto-installer/src/utils.rs | 4 ++-- proxmox-installer-common/src/options.rs | 22 ---------------------- proxmox-tui-installer/src/main.rs | 6 ++---- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/proxmox-auto-installer/src/utils.rs b/proxmox-auto-installer/src/utils.rs index 710af21..a3a07d1 100644 --- a/proxmox-auto-installer/src/utils.rs +++ b/proxmox-auto-installer/src/utils.rs @@ -11,14 +11,14 @@ use proxmox_installer_types::{ answer::{ AutoInstallerConfig, DiskSelection, Filesystem, FilesystemOptions, FilesystemType, FilterMatch, FirstBootHookSourceMode, FqdnConfig, FqdnFromDhcpConfig, FqdnSourceMode, - NetworkConfig, + NetworkConfig, email_validate, }, }; use proxmox_installer_common::{ ROOT_PASSWORD_MIN_LENGTH, disk_checks::check_swapsize, - options::{FilesystemDiskInfo, NetworkInterfacePinningOptions, NetworkOptions, email_validate}, + options::{FilesystemDiskInfo, NetworkInterfacePinningOptions, NetworkOptions}, setup::{ InstallBtrfsOption, InstallConfig, InstallFirstBootSetup, InstallRootPassword, InstallZfsOption, LocaleInfo, RuntimeInfo, SetupInfo, diff --git a/proxmox-installer-common/src/options.rs b/proxmox-installer-common/src/options.rs index 4014c29..220e8cd 100644 --- a/proxmox-installer-common/src/options.rs +++ b/proxmox-installer-common/src/options.rs @@ -519,28 +519,6 @@ impl NetworkOptions { } } -/// Validates an email address using the regex for `` elements -/// as defined in the [HTML specification]. -/// Using that /should/ cover all possible cases that are encountered in the wild. -/// -/// It additionally checks whether the email our default email placeholder value. -/// -/// [HTML specification]: -pub fn email_validate(email: &str) -> Result<()> { - static RE: OnceLock = OnceLock::new(); - let re = RE.get_or_init(|| { - Regex::new(r"^[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])?)*$").unwrap() - }); - - if !re.is_match(email) { - bail!("Email does not look like a valid address (user@domain.tld)") - } else if email == EMAIL_DEFAULT_PLACEHOLDER { - bail!("Invalid (default) email address") - } - - Ok(()) -} - #[cfg(test)] mod tests { use super::*; diff --git a/proxmox-tui-installer/src/main.rs b/proxmox-tui-installer/src/main.rs index 6c457aa..9af6bb1 100644 --- a/proxmox-tui-installer/src/main.rs +++ b/proxmox-tui-installer/src/main.rs @@ -15,13 +15,11 @@ use cursive::{ use proxmox_installer_common::{ ROOT_PASSWORD_MIN_LENGTH, - options::{ - BootdiskOptions, NetworkInterfacePinningOptions, NetworkOptions, TimezoneOptions, - email_validate, - }, + options::{BootdiskOptions, NetworkInterfacePinningOptions, NetworkOptions, TimezoneOptions}, setup::{LocaleInfo, RuntimeInfo, SetupInfo, installer_setup}, }; use proxmox_installer_types::ProxmoxProduct; +use proxmox_installer_types::answer::email_validate; mod options; use options::{InstallerOptions, PasswordOptions}; -- 2.47.3