From: Paul Donald Date: Mon, 12 Jan 2026 00:36:35 +0000 (+0100) Subject: luci-base: amend ZoneSelect widget datatype X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=2a84e490e1b743a208365b542118b40874851e9e;p=openwrt-luci.git luci-base: amend ZoneSelect widget datatype mandate proper firewall compliant zone names. Use validation ucifw4zonename instead of uciname. The former does not permit leading digits which Now we only permit "*" if flags .allowany and .nocreate are set. This is when the widget is used to select pre-existing zones and the zone 'any' ("*") is added as a .value. Creating a zone named "*" shall not be allowed. Signed-off-by: Paul Donald --- diff --git a/modules/luci-base/htdocs/luci-static/resources/tools/widgets.js b/modules/luci-base/htdocs/luci-static/resources/tools/widgets.js index f43c37130a..29552b09ef 100644 --- a/modules/luci-base/htdocs/luci-static/resources/tools/widgets.js +++ b/modules/luci-base/htdocs/luci-static/resources/tools/widgets.js @@ -54,6 +54,13 @@ var CBIZoneSelect = form.ListValue.extend({ var values = L.toArray((cfgvalue != null) ? cfgvalue : this.default), isOutputOnly = false, choices = {}; + let datatype_str = 'ucifw4zonename'; + if (!L.hasSystemFeature('firewall4')) + datatype_str = `and(${datatype_str},maxlength(11))`; + if (this.allowany && this.nocreate) + datatype_str = `or(${datatype_str},"*")`; + if (this.multiple) + datatype_str = `list(${datatype_str})`; if (this.option == 'dest') { for (var i = 0; i < this.section.children.length; i++) { @@ -148,9 +155,7 @@ var CBIZoneSelect = form.ListValue.extend({ display_items: this.display_size || this.size || 3, dropdown_items: this.dropdown_size || this.size || 5, validate: L.bind(this.validate, this, section_id), - datatype: L.hasSystemFeature('firewall4') - ? ( this.multiple ? 'list(or(uciname,"*"))' : 'or(uciname,"*")' ) - : this.multiple ? 'list(or(and(uciname,maxlength(11)),"*"))' : 'or(and(uciname,maxlength(11)),"*")', + datatype: datatype_str, create: !this.nocreate, create_markup: '' + '
  • ' +