Fix issue with verification of ipv4/ipv6 address. (#3162)

This commit is contained in:
Gabriel Beims Bräscher 2019-02-04 15:58:50 -02:00 committed by GitHub
parent 58466c8954
commit f0a2bf93bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 5 deletions

View File

@ -1782,7 +1782,7 @@
label: 'label.ip.address',
validation: {
required: false,
ipv46address: true
ipv4AndIpv6AddressValidator: true
}
}
}

View File

@ -676,7 +676,7 @@ var addGuestNetworkDialog = {
label: 'label.ipv6.gateway',
docID: 'helpGuestNetworkZoneGateway',
validation: {
ipv6: true
ipv6CustomJqueryValidator: true
}
},
ip6cidr: {
@ -689,14 +689,14 @@ var addGuestNetworkDialog = {
label: 'label.ipv6.start.ip',
docID: 'helpGuestNetworkZoneStartIP',
validation: {
ipv6: true
ipv6CustomJqueryValidator: true
}
},
endipv6: {
label: 'label.ipv6.end.ip',
docID: 'helpGuestNetworkZoneEndIP',
validation: {
ipv6: true
ipv6CustomJqueryValidator: true
}
},
//IPv6 (end)
@ -2582,7 +2582,7 @@ $.validator.addMethod("ipv6cidr", function(value, element) {
return false;
}
if (!$.validator.methods.ipv6.call(this, parts[0], element))
if (!$.validator.methods.ipv6CustomJqueryValidator.call(this, parts[0], element))
return false;
if (parts[1] != Number(parts[1]).toString()) //making sure that "", " ", "00", "0 ","2 ", etc. will not pass
@ -2625,6 +2625,23 @@ $.validator.addMethod("ipv46cidr", function(value, element) {
return false;
}, "The specified IPv4/IPv6 CIDR is invalid.");
jQuery.validator.addMethod("ipv4AndIpv6AddressValidator", function(value, element) {
if (this.optional(element) && value.length == 0) {
return true;
}
if (jQuery.validator.methods.ipv4.call(this, value, element) || jQuery.validator.methods.ipv6CustomJqueryValidator.call(this, value, element)) {
return true;
}
return false;
}, "The specified IPv4/IPv6 address is invalid.");
jQuery.validator.addMethod("ipv6CustomJqueryValidator", function(value, element) {
if (value == '::'){
return true;
}
return jQuery.validator.methods.ipv6.call(this, value, element);
}, "The specified IPv6 address is invalid.");
$.validator.addMethod("allzonesonly", function(value, element){