From cd9bd2526a6c7a74d3f8ce3de32bc149d96324f3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 5 Oct 2015 09:30:57 +0200 Subject: [PATCH] Tools::IPV4OCTET: move longer alternatives forward In an alternation /a|b|c/ the first match matches, so while '1.1.1.121' matches /^$IPV4RE$/ (note the ^ and $ anchors), parsing a line like /nameserver ($IPV4RE)/ would only extract '1.1.1.12', ignoring the last '1' due to the /[1-9]/ alternative matching before the /1[0-9]/ one. --- src/PVE/Tools.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm index d5a3866..3f3958e 100644 --- a/src/PVE/Tools.pm +++ b/src/PVE/Tools.pm @@ -47,7 +47,7 @@ my $pvetaskdir = "$pvelogdir/tasks"; mkdir $pvelogdir; mkdir $pvetaskdir; -my $IPV4OCTET = "(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])"; +my $IPV4OCTET = "(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9])?[0-9])"; our $IPV4RE = "(?:(?:$IPV4OCTET\\.){3}$IPV4OCTET)"; my $IPV6H16 = "(?:[0-9a-fA-F]{1,4})"; my $IPV6LS32 = "(?:(?:$IPV4RE|$IPV6H16:$IPV6H16))"; -- 2.39.2