]> git.proxmox.com Git - pve-manager.git/commitdiff
improve gui cidr matching
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 28 Apr 2016 08:39:47 +0000 (10:39 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 28 Apr 2016 08:57:41 +0000 (10:57 +0200)
with this fix, we (again) allow ipv4 cidr to be as low as 8
also check the cidr for ipv6 and show the valid ranges in the
error text

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

index a8089aa85914e51bee7e3777c3d0a822eba2b84b..a701b8f06e4847249a817ccbe31ed34f10922223 100644 (file)
@@ -14,9 +14,12 @@ Ext.apply(Ext.form.field.VTypes, {
     IPAddressMask: /[\d\.]/i,
 
     IPCIDRAddress:  function(v) {
-       return IP4_cidr_match.test(v);
+       var result = IP4_cidr_match.exec(v);
+       // limits according to JSON Schema see
+       // pve-common/src/PVE/JSONSchema.pm
+       return (result !== null && result[1] >= 8 && result[1] <= 32);
     },
-    IPCIDRAddressText:  gettext('Example') + ': 192.168.1.1/24',
+    IPCIDRAddressText:  gettext('Example') + ': 192.168.1.1/24' + "<br>" + gettext('Valid CIDR Range') + ': 8-32',
     IPCIDRAddressMask: /[\d\.\/]/i,
 
     IP6Address:  function(v) {
@@ -26,9 +29,12 @@ Ext.apply(Ext.form.field.VTypes, {
     IP6AddressMask: /[A-Fa-f0-9:]/,
 
     IP6CIDRAddress:  function(v) {
-       return IP6_cidr_match.test(v);
+       var result = IP6_cidr_match.exec(v);
+       // limits according to JSON Schema see
+       // pve-common/src/PVE/JSONSchema.pm
+       return (result !== null && result[1] >= 8 && result[1] <= 120);
     },
-    IP6CIDRAddressText:  gettext('Example') + ': 2001:DB8::42/64',
+    IP6CIDRAddressText:  gettext('Example') + ': 2001:DB8::42/64' + "<br>" + gettext('Valid CIDR Range') + ': 8-120',
     IP6CIDRAddressMask:  /[A-Fa-f0-9:\/]/,
 
     IP6PrefixLength:  function(v) {
index c51fbcd725500b40c92fa7625389cf8a7f4e5927..cf2960684c8c08ceca61f9819f167e34cc6d9367 100644 (file)
@@ -36,7 +36,7 @@ var IPV6_LS32 = "(?:(?:" + IPV6_H16 + ":" + IPV6_H16 + ")|" + IPV4_REGEXP + ")";
 
 
 var IP4_match = new RegExp("^(?:" + IPV4_REGEXP + ")$");
-var IP4_cidr_match = new RegExp("^(?:" + IPV4_REGEXP + ")\/[1-3][0-9]?$");
+var IP4_cidr_match = new RegExp("^(?:" + IPV4_REGEXP + ")\/([0-9]{1,2})$");
 
 var IPV6_REGEXP = "(?:" +
     "(?:(?:"                                                  + "(?:" + IPV6_H16 + ":){6})" + IPV6_LS32 + ")|" +
@@ -51,7 +51,7 @@ var IPV6_REGEXP = "(?:" +
     ")";
 
 var IP6_match = new RegExp("^(?:" + IPV6_REGEXP + ")$");
-var IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/[0-9]{1,3}?$");
+var IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/([0-9]{1,3})$");
 var IP6_bracket_match = new RegExp("^\\[(" + IPV6_REGEXP + ")\\]");
 
 var IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$");