luci-base: amend ZoneSelect widget datatype
authorPaul Donald <redacted>
Mon, 12 Jan 2026 00:36:35 +0000 (01:36 +0100)
committerPaul Donald <redacted>
Mon, 12 Jan 2026 00:36:35 +0000 (01:36 +0100)
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 <redacted>
modules/luci-base/htdocs/luci-static/resources/tools/widgets.js

index f43c37130a76c1b4f00a60436546ecdcfbd85586..29552b09ef45315e2eda3b48e8c4df69be924737 100644 (file)
@@ -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: '' +
                                '<li data-value="{{value}}">' +
git clone https://git.99rst.org/PROJECT