From 79457bdc852ce90e5bf24f7c7cf2366da070d3e5 Mon Sep 17 00:00:00 2001 From: steschuser Date: Sat, 30 Oct 2021 21:06:44 +0200 Subject: [PATCH] Bug domain parse (#936) --- powerdnsadmin/lib/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/powerdnsadmin/lib/utils.py b/powerdnsadmin/lib/utils.py index d7f20a4..d086e81 100644 --- a/powerdnsadmin/lib/utils.py +++ b/powerdnsadmin/lib/utils.py @@ -104,6 +104,13 @@ def fetch_json(remote_url, data = None try: data = json.loads(r.content.decode('utf-8')) + except UnicodeDecodeError: + # If the decoding fails, switch to slower but probably working .json() + try: + logging.warning("UTF-8 content.decode failed, switching to slower .json method") + data = r.json() + except Exception as e: + raise e except Exception as e: raise RuntimeError( 'Error while loading JSON data from {0}'.format(remote_url)) from e