luci-mod-network: handle multiple mac for static lease 4501/head
authorAnsuel Smith <ansuelsmth@gmail.com>
Thu, 8 Oct 2020 00:43:29 +0000 (02:43 +0200)
committerAnsuel Smith <ansuelsmth@gmail.com>
Thu, 8 Oct 2020 00:43:29 +0000 (02:43 +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>
modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js

index 37cc29f32a25b11f6bab0b3c04b2a1be6369c1a3..7f46740da43e55ee70df243d416941597edd2360 100644 (file)
@@ -432,12 +432,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(