From: Jo-Philipp Wich Date: Wed, 5 Oct 2022 21:50:18 +0000 (+0200) Subject: ruleset: properly handle zone names starting with a digit X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=3db474135c62d1eeea7a80dd151d53d94005f1d5;p=project%2Ffirewall4.git 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 --- 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 %}