mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
interfaces_file: re.escape() old value (#880)
This commit is contained in:
parent
253c2179de
commit
748304dadd
2 changed files with 4 additions and 1 deletions
3
changelogs/fragments/777-interfaces_file-re-escape.yml
Normal file
3
changelogs/fragments/777-interfaces_file-re-escape.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
bugfixes:
|
||||
- interfaces_file - escape regular expression characters in old value (https://github.com/ansible-collections/community.general/issues/777).
|
|
@ -284,7 +284,7 @@ def setInterfaceOption(module, lines, iface, option, raw_value, state, address_f
|
|||
address_family = target_option['address_family']
|
||||
prefix_start = old_line.find(option)
|
||||
optionLen = len(option)
|
||||
old_value_position = re.search(r"\s+".join(old_value.split()), old_line[prefix_start + optionLen:])
|
||||
old_value_position = re.search(r"\s+".join(map(re.escape, old_value.split())), old_line[prefix_start + optionLen:])
|
||||
start = old_value_position.start() + prefix_start + optionLen
|
||||
end = old_value_position.end() + prefix_start + optionLen
|
||||
line = old_line[:start] + value + old_line[end:]
|
||||
|
|
Loading…
Reference in a new issue