Skip to content

Commit

Permalink
Fix bug in preprocessing when wrapped line is appended to a non-exist…
Browse files Browse the repository at this point in the history
…ing entry.
  • Loading branch information
felixfontein committed Jun 2, 2023
1 parent 2b8c66b commit bba5bac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/177-facts-parsing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "facts - do not crash in CLI output preprocessing in unexpected situations during line unwrapping (https://github.com/ansible-collections/community.routeros/issues/170, https://github.com/ansible-collections/community.routeros/pull/177)."
4 changes: 2 additions & 2 deletions plugins/modules/facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def preprocess(self, data):
for line in data.split('\n'):
if len(line) == 0 or line[:5] == 'Flags':
continue
elif not re.match(self.WRAPPED_LINE_RE, line):
elif not preprocessed or not re.match(self.WRAPPED_LINE_RE, line):
preprocessed.append(line)
else:
preprocessed[-1] += line
Expand Down Expand Up @@ -468,7 +468,7 @@ def preprocess(self, data):
for line in data.split('\n'):
if len(line) == 0 or line[:5] == 'Flags':
continue
elif not re.match(self.WRAPPED_LINE_RE, line):
elif not preprocessed or not re.match(self.WRAPPED_LINE_RE, line):
preprocessed.append(line)
else:
preprocessed[-1] += line
Expand Down

0 comments on commit bba5bac

Please sign in to comment.