diff --git a/CHANGELOG b/CHANGELOG index fd76a3ae..558479b3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,8 @@ jc changelog 20230103 v1.22.5 - Update copyright dates - Fix INI parser to include top-level values with no section header +- Fix INI and Key/Value parsers to only remove one quotation mark from the + beginning and end of values. 20221230 v1.22.4 - Add `iwconfig` command parser diff --git a/jc/parsers/ini.py b/jc/parsers/ini.py index 96dce33a..e81e4e30 100644 --- a/jc/parsers/ini.py +++ b/jc/parsers/ini.py @@ -107,10 +107,10 @@ def _process(proc_data): for heading in proc_data: for key, value in proc_data[heading].items(): if value is not None and value.startswith('"') and value.endswith('"'): - proc_data[heading][key] = value.lstrip('"').rstrip('"') + proc_data[heading][key] = value[1:-1] elif value is not None and value.startswith("'") and value.endswith("'"): - proc_data[heading][key] = value.lstrip("'").rstrip("'") + proc_data[heading][key] = value[1:-1] elif value is None: proc_data[heading][key] = '' diff --git a/jc/parsers/kv.py b/jc/parsers/kv.py index 0cc47c69..de1b4421 100644 --- a/jc/parsers/kv.py +++ b/jc/parsers/kv.py @@ -83,10 +83,10 @@ def _process(proc_data): # remove quotation marks from beginning and end of values for key in proc_data: if proc_data[key] is not None and proc_data[key].startswith('"') and proc_data[key].endswith('"'): - proc_data[key] = proc_data[key].lstrip('"').rstrip('"') + proc_data[key] = proc_data[key][1:-1] elif proc_data[key] is not None and proc_data[key].startswith("'") and proc_data[key].endswith("'"): - proc_data[key] = proc_data[key].lstrip("'").rstrip("'") + proc_data[key] = proc_data[key][1:-1] elif proc_data[key] is None: proc_data[key] = ''