mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 11:10:21 -07:00
nxos_vlan: vlan names containing regex ctl chars should be escaped (#55463)
The `nxos_vlan` module may raise with regex error `sre_constants.error: multiple repeat` in the non_structured codepath if the device has existing vlan names with certain regex control characters; e.g. ``` VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Eth1/3 14 my-vlan-name-is-*** active ```
This commit is contained in:
parent
869fdcd7d4
commit
de8ce08fd8
1 changed files with 2 additions and 3 deletions
|
@ -496,8 +496,7 @@ def parse_vlan_non_structured(module, netcfg, vlans):
|
||||||
if name_match:
|
if name_match:
|
||||||
name = name_match.group(1)
|
name = name_match.group(1)
|
||||||
obj['name'] = name
|
obj['name'] = name
|
||||||
|
state_match = re.search(r'{0}\s*{1}\s*(\S+)'.format(vlan_id, re.escape(name)), vlan, re.M)
|
||||||
state_match = re.search(r'{0}\s*{1}\s*(\S+)'.format(vlan_id, name), vlan, re.M)
|
|
||||||
if state_match:
|
if state_match:
|
||||||
vlan_state_match = state_match.group(1)
|
vlan_state_match = state_match.group(1)
|
||||||
if vlan_state_match == 'suspended':
|
if vlan_state_match == 'suspended':
|
||||||
|
@ -518,7 +517,7 @@ def parse_vlan_non_structured(module, netcfg, vlans):
|
||||||
|
|
||||||
vlan = ','.join(vlan.splitlines())
|
vlan = ','.join(vlan.splitlines())
|
||||||
interfaces = list()
|
interfaces = list()
|
||||||
intfs_match = re.search(r'{0}\s*{1}\s*{2}\s*(.*)'.format(vlan_id, name, vlan_state_match),
|
intfs_match = re.search(r'{0}\s*{1}\s*{2}\s*(.*)'.format(vlan_id, re.escape(name), vlan_state_match),
|
||||||
vlan, re.M)
|
vlan, re.M)
|
||||||
if intfs_match:
|
if intfs_match:
|
||||||
intfs = intfs_match.group(1)
|
intfs = intfs_match.group(1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue