summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static/resources
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-07-03 20:10:22 +0200
committerJo-Philipp Wich <jo@mein.io>2021-07-03 20:12:33 +0200
commit00e41c3c4977f75e6ca43429dd4c8c2f5cb22419 (patch)
treed95a923874ceb9ecac20840aad6cf9c34c6a6ad7 /modules/luci-base/htdocs/luci-static/resources
parent38400c484e0f19307e374c8dc1d8084bbf61f1f4 (diff)
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>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/validation.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/validation.js b/modules/luci-base/htdocs/luci-static/resources/validation.js
index 28042ba8cd..70d3a7e73a 100644
--- a/modules/luci-base/htdocs/luci-static/resources/validation.js
+++ b/modules/luci-base/htdocs/luci-static/resources/validation.js
@@ -338,9 +338,10 @@ var ValidatorFactory = baseclass.extend({
return this.assert(this.apply('port'), _('valid port or port range (port1-port2)'));
},
- macaddr: function() {
- return this.assert(this.value.match(/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/) != null,
- _('valid MAC address'));
+ macaddr: function(multicast) {
+ var m = this.value.match(/^([a-fA-F0-9]{2}):([a-fA-F0-9]{2}:){4}[a-fA-F0-9]{2}$/);
+ return this.assert(m != null && !(+m[1] & 1) == !multicast,
+ multicast ? _('valid multicast MAC address') : _('valid MAC address'));
},
host: function(ipv4only) {