This is an automated email from the ASF dual-hosted git repository. gabriel pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push: new f0a2bf9 Fix issue with verification of ipv4/ipv6 address. (#3162) f0a2bf9 is described below commit f0a2bf93bf009b880f8e08cacfede8d254900c00 Author: Gabriel Beims Bräscher <gabrasc...@gmail.com> AuthorDate: Mon Feb 4 15:58:50 2019 -0200 Fix issue with verification of ipv4/ipv6 address. (#3162) --- ui/scripts/network.js | 2 +- ui/scripts/sharedFunctions.js | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index b3c2261..f4530d7 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -1782,7 +1782,7 @@ label: 'label.ip.address', validation: { required: false, - ipv46address: true + ipv4AndIpv6AddressValidator: true } } } diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js index e531b1e..fdff4dd 100644 --- a/ui/scripts/sharedFunctions.js +++ b/ui/scripts/sharedFunctions.js @@ -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){