]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
Utils: improve matching groups of ip/host regexes
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 1 Oct 2020 07:57:54 +0000 (09:57 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 1 Oct 2020 08:09:41 +0000 (10:09 +0200)
we only ever want to match the whole hostname/ip, never just some part of it
and we do not want to have the ':' as part of the port

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/Utils.js

index 8595ccec41e00aed5790af1a6ad5cfcd0e35674c..232c97c50ceef8b97535ae62576dcc2ae0388a16 100644 (file)
@@ -873,12 +873,12 @@ utilities: {
        me.IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$");
        me.IP64_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + "/" + IPV6_CIDR_MASK + ")|(?:" + IPV4_REGEXP + "/" + IPV4_CIDR_MASK + ")$");
 
-       let DnsName_REGEXP = "(?:(([a-zA-Z0-9]([a-zA-Z0-9\\-]*[a-zA-Z0-9])?)\\.)*([A-Za-z0-9]([A-Za-z0-9\\-]*[A-Za-z0-9])?))";
+       let DnsName_REGEXP = "(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?)\\.)*(?:[A-Za-z0-9](?:[A-Za-z0-9\\-]*[A-Za-z0-9])?))";
        me.DnsName_match = new RegExp("^" + DnsName_REGEXP + "$");
 
-       me.HostPort_match = new RegExp("^(" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")(:\\d+)?$");
-       me.HostPortBrackets_match = new RegExp("^\\[(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")\\](:\\d+)?$");
-       me.IP6_dotnotation_match = new RegExp("^" + IPV6_REGEXP + "(\\.\\d+)?$");
+       me.HostPort_match = new RegExp("^(" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")(?::(\\d+))?$");
+       me.HostPortBrackets_match = new RegExp("^\\[(" + IPV6_REGEXP + "|" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")\\](?::(\\d+))?$");
+       me.IP6_dotnotation_match = new RegExp("^(" + IPV6_REGEXP + ")(?:\\.(\\d+))?$");
        me.Vlan_match = /^vlan(\\d+)/;
        me.VlanInterface_match = /(\\w+)\\.(\\d+)/;
     },