]> git.proxmox.com Git - pve-common.git/commitdiff
Tools::IPV4OCTET: move longer alternatives forward
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 5 Oct 2015 07:30:57 +0000 (09:30 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 5 Oct 2015 10:31:24 +0000 (12:31 +0200)
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

index d5a386621d1054ebea388de3fcd2c1e274aef3a1..3f3958e0e354f4f5f4cbe6fea92028fdd58f6e19 100644 (file)
@@ -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))";