diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2023-08-30 22:39:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-30 22:39:59 +0300 |
commit | abf824cddbb5712e92322c9137b2280d9fd3db63 (patch) | |
tree | c89db7fc1f8e275a1ec9c5a856472516c09d7728 /python | |
parent | a5c5998a84917cc45f9fb3234607f53b27a109fc (diff) | |
parent | a8777563f19fe5f9f190b96a61b6bab8cdcd58d2 (diff) | |
download | vyos-1x-abf824cddbb5712e92322c9137b2280d9fd3db63.tar.gz vyos-1x-abf824cddbb5712e92322c9137b2280d9fd3db63.zip |
Merge pull request #2187 from sever-sever/T4933-eq
vyos.util: T4933: informative error for bad colon-separated lines
Diffstat (limited to 'python')
-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 4df046a36..03809fc83 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -349,9 +349,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)) |