From 3db474135c62d1eeea7a80dd151d53d94005f1d5 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 5 Oct 2022 23:50:18 +0200 Subject: [PATCH] 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 --- root/usr/share/firewall4/templates/ruleset.uc | 4 ++-- 1 file 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 %} -- 2.30.2