1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

fix for blank target in rule

This commit is contained in:
Kelly Brazil
2023-10-24 16:17:53 -07:00
parent 59b89ecbd4
commit b70025d6d6
2 changed files with 8 additions and 7 deletions

View File

@ -1,7 +1,7 @@
jc changelog
20231023 v1.23.7
- xxx
20231024 v1.23.7
- Fix `iptables` parser for cases where the `target` field is blank in a rule
20231023 v1.23.6
- Fix XML parser for xmltodict library versions < 0.13.0

View File

@ -163,7 +163,7 @@ import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.8'
version = '1.9'
description = '`iptables` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -271,6 +271,10 @@ def parse(data, raw=False, quiet=False):
continue
else:
# sometimes the "target" column is blank. Stuff in a dummy character
if headers[0] == 'target' and line.startswith(' '):
line = '\u2063' + line
rule = line.split(maxsplit=len(headers) - 1)
temp_rule = dict(zip(headers, rule))
if temp_rule:
@ -279,7 +283,4 @@ def parse(data, raw=False, quiet=False):
if chain:
raw_output.append(chain)
if raw:
return raw_output
else:
return _process(raw_output)
return raw_output if raw else _process(raw_output)