luci-base: validation: disallow mutlicast MACs by default
Extend the MAC address validator to disallow multicast MAC addresses and add a new optional validator option to require multicast MACs instead of unicast ones. Fixes: #5166 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
38400c484e
commit
00e41c3c49
1 changed files with 4 additions and 3 deletions
|
@ -338,9 +338,10 @@ var ValidatorFactory = baseclass.extend({
|
||||||
return this.assert(this.apply('port'), _('valid port or port range (port1-port2)'));
|
return this.assert(this.apply('port'), _('valid port or port range (port1-port2)'));
|
||||||
},
|
},
|
||||||
|
|
||||||
macaddr: function() {
|
macaddr: function(multicast) {
|
||||||
return this.assert(this.value.match(/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/) != null,
|
var m = this.value.match(/^([a-fA-F0-9]{2}):([a-fA-F0-9]{2}:){4}[a-fA-F0-9]{2}$/);
|
||||||
_('valid MAC address'));
|
return this.assert(m != null && !(+m[1] & 1) == !multicast,
|
||||||
|
multicast ? _('valid multicast MAC address') : _('valid MAC address'));
|
||||||
},
|
},
|
||||||
|
|
||||||
host: function(ipv4only) {
|
host: function(ipv4only) {
|
||||||
|
|
Loading…
Reference in a new issue