summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich2022-10-05 21:50:18 +0000
committerJo-Philipp Wich2022-10-05 21:50:18 +0000
commit3db474135c62d1eeea7a80dd151d53d94005f1d5 (patch)
treec66a2dc7022d3d0b7dfb9e0a3b6be714585d3b2f
parent43d8ef516747aaede640d292b0326a66186809a8 (diff)
downloadfirewall4-3db474135c62d1eeea7a80dd151d53d94005f1d5.tar.gz
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>
-rw-r--r--root/usr/share/firewall4/templates/ruleset.uc4
1 files changed, 2 insertions, 2 deletions
diff --git a/root/usr/share/firewall4/templates/ruleset.uc b/root/usr/share/firewall4/templates/ruleset.uc
index eaa1f04..2e33d5d 100644
--- a/root/usr/share/firewall4/templates/ruleset.uc
+++ b/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 %}