all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox] proxmox/tools/common_regex: improve IPRE_BRACKET
@ 2020-09-29 14:05 Dominik Csapak
  0 siblings, 0 replies; only message in thread
From: Dominik Csapak @ 2020-09-29 14:05 UTC (permalink / raw)
  To: pbs-devel

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 <d.csapak@proxmox.com>
---
 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





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-29 14:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 14:05 [pbs-devel] [PATCH proxmox] proxmox/tools/common_regex: improve IPRE_BRACKET Dominik Csapak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal