1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

ifupdownmain: syntax-check: l2protocol-tunnel: replace regex with str.split()

Seems like the regex module might be behave a little bit different in python3.
The regexes used to validate l2protocol-tunnel were returning incorrect lists:

value=lldp,stp
regex=['', 'l', 'l', 'd', 'p', '', 's', 't', 'p', '']

the patch simplifies the code by using str.translate and str.split

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
Julien Fortin
2020-05-02 19:14:09 +02:00
parent 580a567b25
commit 3101ff1d6f

View File

@@ -1048,11 +1048,11 @@ class ifupdownMain:
if '=' in value:
for intf_arg in value.split():
intf_arg_split = intf_arg.split('=')
for arg in re.split(',|\s*', intf_arg_split[1]):
for arg in intf_arg_split[1].replace(",", " ").split():
if arg not in ['all', 'stp', 'lldp', 'lacp', 'cdp', 'pvst']:
return False
else:
for arg in re.split(',|\s*', value):
for arg in value.replace(",", " ").split():
if arg not in ['all', 'stp', 'lldp', 'lacp', 'cdp', 'pvst']:
return False
except: