From 9af2c207066666e4401b73323f33313488e115dd Mon Sep 17 00:00:00 2001 From: ThomasV Date: Fri, 5 Sep 2014 12:12:00 +0200 Subject: [PATCH] json sanitize labels --- plugins/labels.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/labels.py b/plugins/labels.py index 16aabf8d..57f63a37 100644 --- a/plugins/labels.py +++ b/plugins/labels.py @@ -219,9 +219,16 @@ class Plugin(BasePlugin): for label in response: decoded_key = self.decode(label["external_id"]) - decoded_label = self.decode(label["text"]) + decoded_label = self.decode(label["text"]) + try: + json.dumps(decoded_key) + json.dumps(decoded_label) + except: + print_error('json error: cannot save label', decoded_key) + continue if force or not self.wallet.labels.get(decoded_key): self.wallet.labels[decoded_key] = decoded_label + self.wallet.storage.put('labels', self.wallet.labels) return True except socket.gaierror as e: print_error('Error connecting to service: %s ' % e)