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 88FAE622A3 for ; Tue, 29 Sep 2020 16:05:20 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7E29C107A1 for ; Tue, 29 Sep 2020 16:05:20 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 5C2D610796 for ; Tue, 29 Sep 2020 16:05:19 +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 28B1145870 for ; Tue, 29 Sep 2020 16:05:19 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Tue, 29 Sep 2020 16:05:18 +0200 Message-Id: <20200929140518.24000-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.532 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods NO_DNS_FOR_FROM 0.379 Envelope sender has no MX or A DNS records RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record SUBJ_OBFU_PUNCT_FEW 0.749 Possible punctuation-obfuscated Subject: header Subject: [pbs-devel] [PATCH proxmox] proxmox/tools/common_regex: improve IPRE_BRACKET X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Sep 2020 14:05:20 -0000 by disallowing [] around ipv4 adresses (which is not very common) we did not use this anywhere, so there should not be any compatibility problem Signed-off-by: Dominik Csapak --- proxmox/src/tools/common_regex.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/proxmox/src/tools/common_regex.rs b/proxmox/src/tools/common_regex.rs index 6b1d037..8fe3067 100644 --- a/proxmox/src/tools/common_regex.rs +++ b/proxmox/src/tools/common_regex.rs @@ -41,14 +41,14 @@ macro_rules! IPV6RE { () => (concat!(r"(?:", macro_rules! IPRE { () => (concat!(r"(?:", IPV4RE!(), "|", IPV6RE!(), ")")) } /// Regular expression string to match IP addresses where IPv6 addresses require brackets around -/// them, while for IPv4 they are optional. +/// them, while for IPv4 they are forbidden. #[rustfmt::skip] #[macro_export] macro_rules! IPRE_BRACKET { () => ( concat!(r"(?:", IPV4RE!(), r"|\[(?:", - IPV4RE!(), "|", IPV6RE!(), + IPV6RE!(), r")\]", r")")) } @@ -71,7 +71,6 @@ fn test_regexes() { assert!(IP_REGEX.is_match("2014:b3a:0102:adf1:1234:4321:4afA:BCDF")); assert!(IP_BRACKET_REGEX.is_match("127.0.0.1")); - assert!(IP_BRACKET_REGEX.is_match("[127.0.0.1]")); assert!(IP_BRACKET_REGEX.is_match("[::1]")); assert!(IP_BRACKET_REGEX.is_match("[2014:b3a::27]")); assert!(IP_BRACKET_REGEX.is_match("[2014:b3a::192.168.0.1]")); -- 2.20.1