luci-mod-network: handle multiple mac for static lease
authorAnsuel Smith <ansuelsmth@gmail.com>
Thu, 8 Oct 2020 00:43:29 +0000 (02:43 +0200)
committerJo-Philipp Wich <jo@mein.io>
Thu, 8 Jul 2021 06:27:20 +0000 (08:27 +0200)
The mac section for the static lease doesn't correctly handle when multiple mac are set for a rule.
Fixes: #4291
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
(cherry picked from commit 6c9a6c334e2fa55f4b64b64b85e0b104f0b99037)

modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js

index 6693dc0eacf4868a8900da94889b8a8dee4293d8..886271b13dbe5de8995e8be7ab6f25846d17201f 100644 (file)
@@ -425,12 +425,9 @@ return view.extend({
                so.datatype = 'list(unique(macaddr))';
                so.rmempty  = true;
                so.cfgvalue = function(section) {
-                       var macs = uci.get('dhcp', section, 'mac'),
+                       var macs = L.toArray(uci.get('dhcp', section, 'mac')),
                            result = [];
 
-                       if (!Array.isArray(macs))
-                               macs = (macs != null && macs != '') ? macs.split(/\ss+/) : [];
-
                        for (var i = 0, mac; (mac = macs[i]) != null; i++)
                                if (/^([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2})$/.test(mac))
                                        result.push('%02X:%02X:%02X:%02X:%02X:%02X'.format(