mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix sanitizing config lines (#50553)
Previously, the index got out of sync with the actual config list. Invoked with lines: - bad - first - bad - second the sanitization would first delete index 0 and then index 2, which would result in the output - first - bad By reversing the list, we avoid that problem (though a filter() would be nicer)
This commit is contained in:
parent
cb89b1758d
commit
636e1d5fcb
1 changed files with 1 additions and 1 deletions
|
@ -207,7 +207,7 @@ def diff_config(commands, config):
|
||||||
def sanitize_config(config, result):
|
def sanitize_config(config, result):
|
||||||
result['filtered'] = list()
|
result['filtered'] = list()
|
||||||
for regex in CONFIG_FILTERS:
|
for regex in CONFIG_FILTERS:
|
||||||
for index, line in enumerate(list(config)):
|
for index, line in reversed(list(enumerate(config))):
|
||||||
if regex.search(line):
|
if regex.search(line):
|
||||||
result['filtered'].append(line)
|
result['filtered'].append(line)
|
||||||
del config[index]
|
del config[index]
|
||||||
|
|
Loading…
Reference in a new issue