From 5e598c5337a3a1abf91609b7f10f546957157907 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 17 Apr 2014 13:18:57 -0500 Subject: [PATCH] Fix handling of non-JSON lines in responses Garbage lines with ' = ' in them were causing parsing errors, where key=val lines should not have spaces around the equals. Fixes #6962 --- lib/ansible/utils/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index ff73e0629a5..a32e577f509 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -884,10 +884,11 @@ def filter_leading_non_json_lines(buf): filter only leading lines since multiline JSON is valid. ''' + kv_regex = re.compile(r'.*\w+=\w+.*') filtered_lines = StringIO.StringIO() stop_filtering = False for line in buf.splitlines(): - if stop_filtering or "=" in line or line.startswith('{') or line.startswith('['): + if stop_filtering or kv_regex.match(line) or line.startswith('{') or line.startswith('['): stop_filtering = True filtered_lines.write(line + '\n') return filtered_lines.getvalue()