summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-01-12 17:59:34 +0100
committerGitHub <noreply@github.com>2023-01-12 17:59:34 +0100
commit9804a878aa929946b280ded9ae6d1379f94044ad (patch)
tree5a702211858efc8cfb6399a447f6f72f422bd6d2 /python/vyos
parent640856694b547ce172874a6f90046588009f11a9 (diff)
parentfb7f162f61522127ca72adffd6802797b136a99a (diff)
downloadvyos-1x-9804a878aa929946b280ded9ae6d1379f94044ad.tar.gz
vyos-1x-9804a878aa929946b280ded9ae6d1379f94044ad.zip
Merge pull request #1751 from dmbaturin/colon-separated-error
vyos.util: T4933: informative error for bad colon-separated lines in vyos.util.colon_separated_to_dict
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/util.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 6a828c0ac..110da3be5 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -348,9 +348,11 @@ def colon_separated_to_dict(data_string, uniquekeys=False):
l = l.strip()
if l:
match = re.match(key_value_re, l)
- if match:
+ if match and (len(match.groups()) == 2):
key = match.groups()[0].strip()
value = match.groups()[1].strip()
+ else:
+ raise ValueError(f"""Line "{l}" could not be parsed a colon-separated pair """, l)
if key in data.keys():
if uniquekeys:
raise ValueError("Data string has duplicate keys: {0}".format(key))