commit 9af2c207066666e4401b73323f33313488e115dd parent 0c8c21f64d513a7c5be8f27e8a822b5b54b3472c Author: ThomasV <thomasv@gitorious> Date: Fri, 5 Sep 2014 12:12:00 +0200 json sanitize labels Diffstat:
M | plugins/labels.py | | | 9 | ++++++++- |
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git 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)