luci-mod-network: improve static lease ip validation logic
authorPaul Donald <newtwen@gmail.com>
Thu, 25 Jan 2024 00:05:15 +0000 (01:05 +0100)
committerPaul Donald <newtwen@gmail.com>
Thu, 25 Jan 2024 00:27:51 +0000 (01:27 +0100)
m (mac) is an array, and is zero length or greater.

Signed-off-by: Paul Donald <newtwen@gmail.com>
(cherry picked from commit f6cbda00e77afc26c12da3c31e5f5444cee17422)

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

index a123f9b342472043e9247c3a66eb3ef1086c42e5..889f132ab086957201128ac267a2df4cdaa42ba7 100644 (file)
@@ -843,10 +843,10 @@ return view.extend({
                        var m = this.section.formvalue(section, 'mac'),
                            n = this.section.formvalue(section, 'name');
 
-                       if ((m == null || m == '') && (n == null || n == ''))
+                       if ((m && !m.length > 0) && !n)
                                return _('One of hostname or MAC address must be specified!');
 
-                       if (value == null || value == '' || value == 'ignore')
+                       if (!value || value == 'ignore')
                                return true;
 
                        var leases = uci.sections('dhcp', 'host');