From 8f954673abdbbd4d9b9da3eacc61b335b4909f89 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Fri, 28 Feb 2020 09:07:36 -0800 Subject: [PATCH] use shlex split for values within quotations that have spaces --- jc/parsers/blkid.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jc/parsers/blkid.py b/jc/parsers/blkid.py index 4854c4b6..1e5923c7 100644 --- a/jc/parsers/blkid.py +++ b/jc/parsers/blkid.py @@ -74,6 +74,7 @@ Examples: } ] """ +import shlex import jc.utils @@ -183,12 +184,12 @@ def parse(data, raw=False, quiet=False): for line in linedata: output_line = {} - entries = line.split() + entries = shlex.split(line) output_line['device'] = entries.pop(0)[:-1] for entry in entries: key = entry.split('=')[0].lower() - value = entry.split('=')[1].replace('"', '') + value = entry.split('=')[1] output_line[key] = value raw_output.append(output_line)