From c036e37357141bb71a38df174e21101151e52620 Mon Sep 17 00:00:00 2001 From: Oleksandr Kuchmystyi Date: Mon, 30 Mar 2026 17:10:17 +0300 Subject: firewall: T8275: Resolve migration issue for 'weekdays' option from 1.3.8 Fix error parsing for day of week while loading firewall configuration. --- python/vyos/firewall.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/vyos/firewall.py b/python/vyos/firewall.py index 04e59eb25..c655e2de8 100755 --- a/python/vyos/firewall.py +++ b/python/vyos/firewall.py @@ -662,6 +662,19 @@ def parse_tcp_flags(flags): exclude = list(flags['not']) if 'not' in flags else [] return f'tcp flags & ({"|".join(include + exclude)}) == {"|".join(include) if include else "0x0"}' +def expand_weekday(abbrev: str) -> str: + mapping = { + 'mon': 'monday', + 'tue': 'tuesday', + 'wed': 'wednesday', + 'thu': 'thursday', + 'fri': 'friday', + 'sat': 'saturday', + 'sun': 'sunday', + } + return mapping.get(abbrev.lower(), abbrev).lower() + + def parse_time(time): out = [] if 'startdate' in time: @@ -679,7 +692,7 @@ def parse_time(time): if 'stoptime' in time and 'stopdate' not in time: out.append(f'hour < "{time["stoptime"]}"') if 'weekdays' in time: - days = time['weekdays'].split(",") - out_days = [f'"{day}"' for day in days if day[0] != '!'] + days = [day.strip() for day in time['weekdays'].split(",") if day] + out_days = [f'"{expand_weekday(day).title()}"' for day in days if day[0] != '!'] out.append(f'day {{{",".join(out_days)}}}') return " ".join(out) -- cgit v1.2.3