From 24af9a631682c1d2285895d9f91b681f9d384f26 Mon Sep 17 00:00:00 2001 From: Vadim Rutkovsky Date: Thu, 20 Oct 2016 13:40:45 +0200 Subject: [PATCH] metrics: properly escape commas in exception text The most secure way is using json.dumps --- metrics.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metrics.py b/metrics.py index 31d05bc..2932946 100644 --- a/metrics.py +++ b/metrics.py @@ -149,7 +149,9 @@ def get_stats(self): errors = plugins_metadata['errors'] first_failed = sorted(errors.keys())[0] plugins['failed_plugin'] = first_failed - plugins['exception'] = errors[first_failed].split("(")[0].replace(',', ' ') + exception_text = errors[first_failed].split("(")[0] + # Make sure quotes and commas are escaped + plugins['exception'] = json.dumps(exception_text) except (KeyError, IndexError): pass