diff options
author | Daniil Baturin <daniil@baturin.org> | 2023-01-12 12:18:15 +0000 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2023-01-12 12:25:18 +0000 |
commit | fb7f162f61522127ca72adffd6802797b136a99a (patch) | |
tree | 54b480a614f571843b47277f123bf8163fc69581 | |
parent | 0e5ea5a63ab9db9ae04ab09e3af42a6e8e1c4c55 (diff) | |
download | vyos-1x-fb7f162f61522127ca72adffd6802797b136a99a.tar.gz vyos-1x-fb7f162f61522127ca72adffd6802797b136a99a.zip |
vyos.util: T4933: informative error for bad colon-separated lines
in vyos.util.colon_separated_to_dict
-rw-r--r-- | python/vyos/util.py | 4 |
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)) |