From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 6A54C851B for ; Wed, 21 Jun 2023 14:45:36 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4A7481D807 for ; Wed, 21 Jun 2023 14:45:36 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 21 Jun 2023 14:45:35 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 45B2A422F9 for ; Wed, 21 Jun 2023 14:45:35 +0200 (CEST) Date: Wed, 21 Jun 2023 14:45:34 +0200 (CEST) From: Maximiliano Sandoval To: Proxmox VE development discussion , Dominik Csapak Message-ID: <1193072501.600.1687351534134@webmail.proxmox.com> In-Reply-To: <20230621123032.744374-2-d.csapak@proxmox.com> References: <20230621123032.744374-1-d.csapak@proxmox.com> <20230621123032.744374-2-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.6-Rev47 X-Originating-Client: open-xchange-appsuite X-SPAM-LEVEL: Spam detection results: 0 AWL -0.000 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [docs.rs, whatwg.org, main.rs, proxmox.com] Subject: Re: [pve-devel] [PATCH 2/2] tui: verify email with basic regex 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: , X-List-Received-Date: Wed, 21 Jun 2023 12:45:36 -0000 Note that the HTML5 standard [1] suggests /^[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])?)*$/ as a regex, I am not sure whats the difference but it might be worth it to check if there is any relevant difference. This is used by the validator crate [2] for example. [1] https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address [2] https://docs.rs/validator/latest/validator/fn.validate_email.html > On 21.06.2023 14:30 CEST Dominik Csapak wrote: > > > regex copied from perl gui installer > > Signed-off-by: Dominik Csapak > --- > this needs librust-regex-dev as build-dependency > proxmox-tui-installer/Cargo.toml | 1 + > proxmox-tui-installer/src/main.rs | 8 ++++++++ > 2 files changed, 9 insertions(+) > > diff --git a/proxmox-tui-installer/Cargo.toml b/proxmox-tui-installer/Cargo.toml > index 9d57b5b..5a50c69 100644 > --- a/proxmox-tui-installer/Cargo.toml > +++ b/proxmox-tui-installer/Cargo.toml > @@ -11,5 +11,6 @@ homepage = "https://www.proxmox.com" > cursive = { version = "0.20.0", default-features = false, features = ["termion-backend"] } > serde = { version = "1.0", features = ["derive"] } > serde_json = "1.0" > +regex = "1.7" > > proxmox-sys = "0.5.0" > diff --git a/proxmox-tui-installer/src/main.rs b/proxmox-tui-installer/src/main.rs > index 77cfb63..2d048f0 100644 > --- a/proxmox-tui-installer/src/main.rs > +++ b/proxmox-tui-installer/src/main.rs > @@ -25,6 +25,8 @@ use cursive::{ > Cursive, CursiveRunnable, ScreenId, View, XY, > }; > > +use regex::Regex; > + > use proxmox_sys::linux::procfs; > > mod options; > @@ -484,12 +486,18 @@ fn password_dialog(siv: &mut Cursive) -> InstallerView { > .get_value::(2) > .ok_or("failed to retrieve email")?; > > + let email_regex = > + Regex::new(r"^[\w\+\-\~]+(\.[\w\+\-\~]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*$") > + .unwrap(); > + > if root_password.len() < 5 { > Err("password too short") > } else if root_password != confirm_password { > Err("passwords do not match") > } else if email == "mail@example.invalid" { > Err("invalid email address") > + } else if !email_regex.is_match(&email) { > + Err("Email does not look like a valid address (user@domain.tld)") > } else { > Ok(PasswordOptions { > root_password, > -- > 2.30.2 > > > > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel