Browse Source

ruleset: properly handle zone names starting with a digit

When forming the device and subnet define name, prepend zone name with
an underscore in case it starts with a digit in order to avoid generating
invalid syntax.

Ref: https://github.com/openwrt/openwrt/issues/10693
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Jo-Philipp Wich 1 year ago
parent
commit
3db474135c
1 changed files with 2 additions and 2 deletions
  1. 2 2
      root/usr/share/firewall4/templates/ruleset.uc

+ 2 - 2
root/usr/share/firewall4/templates/ruleset.uc

@@ -73,8 +73,8 @@ table inet fw4 {
 	#
 
 {% for (let zone in fw4.zones()): %}
-	define {{ zone.name }}_devices = {{ fw4.set(zone.match_devices, true) }}
-	define {{ zone.name }}_subnets = {{ fw4.set(zone.match_subnets, true) }}
+	define {{ replace(zone.name, /^[0-9]/, '_$&') }}_devices = {{ fw4.set(zone.match_devices, true) }}
+	define {{ replace(zone.name, /^[0-9]/, '_$&') }}_subnets = {{ fw4.set(zone.match_subnets, true) }}
 
 {% endfor %}