summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2023-03-10 13:54:37 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2023-03-10 14:01:48 +0000
commit9701cbe89dbb22d6d0e95f21eeedb6fc78e196c9 (patch)
treef1cf6b0ee050df80a397e8254b30e68da9c8bb08 /python
parent29d27c392274e2d1b5d76690c8fdfee2f55edb00 (diff)
downloadvyos-1x-9701cbe89dbb22d6d0e95f21eeedb6fc78e196c9.tar.gz
vyos-1x-9701cbe89dbb22d6d0e95f21eeedb6fc78e196c9.zip
T5058: Fix range_to_regex list argument
Values of the list for the 'range_to_regex' could be not only range values as ['10-20', '22-30'] but also and not range values like ['10-20', '30', '80'] Fix if we args is list and non range values are exists in ths list % range_to_regex(['10-20', '80']) '(1\\d|20|80)'
Diffstat (limited to 'python')
-rw-r--r--python/vyos/template.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/python/vyos/template.py b/python/vyos/template.py
index 7f417992e..06a292706 100644
--- a/python/vyos/template.py
+++ b/python/vyos/template.py
@@ -675,7 +675,10 @@ def range_to_regex(num_range):
if isinstance(num_range, list):
data = []
for entry in num_range:
- data.append(range_to_regex(entry))
+ if '-' not in entry:
+ data.append(entry)
+ else:
+ data.append(range_to_regex(entry))
return f'({"|".join(data)})'
if '-' not in num_range: