fix trailing
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 8s

This commit is contained in:
2026-01-11 17:59:08 +01:00
parent 73a945dbe3
commit 20c77739ba

View File

@@ -393,7 +393,14 @@ def nft_list_rules(table: str = DEFAULT_TABLE, chain: str = DEFAULT_CHAIN) -> Di
nft_rule_text_full = text_map[handle] nft_rule_text_full = text_map[handle]
# remove trailing ' handle N' to get copy/paste clause # remove trailing ' handle N' to get copy/paste clause
m = HANDLE_RE.search(nft_rule_text_full) m = HANDLE_RE.search(nft_rule_text_full)
nft_rule_text = nft_rule_text_full[: m.start()].strip() if m else nft_rule_text_full if m:
# slice everything before ' handle N'
raw_clause = nft_rule_text_full[: m.start()].strip()
else:
raw_clause = nft_rule_text_full
# remove a trailing lone '#' (and surrounding whitespace) if present
# e.g. "meta iifname \"eth0\" # " -> "meta iifname \"eth0\""
nft_rule_text = re.sub(r"\s*#\s*$", "", raw_clause).strip()
add_command = f"add rule {table_name} {chain_name} {nft_rule_text}".strip() if nft_rule_text else None add_command = f"add rule {table_name} {chain_name} {nft_rule_text}".strip() if nft_rule_text else None
logger.debug("Attached textual rule for handle %s", handle) logger.debug("Attached textual rule for handle %s", handle)
else: else: