From d241b90b63a18956231600a4f4a3cf916c60074a Mon Sep 17 00:00:00 2001 From: j Date: Fri, 19 Feb 2016 18:46:53 +0530 Subject: [PATCH] check data is a dict --- pandora/archive/views.py | 2 +- pandora/edit/models.py | 2 +- pandora/itemlist/models.py | 2 +- pandora/user/models.py | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pandora/archive/views.py b/pandora/archive/views.py index 8c406b22..c563c34b 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -210,7 +210,7 @@ def addMedia(request, data): else: extension = 'webm' f.selected = True - if 'info' in data and data['info']: + if 'info' in data and data['info'] and isinstance(data['info'], dict): f.info = data['info'] f.info['extension'] = extension f.parse_info() diff --git a/pandora/edit/models.py b/pandora/edit/models.py index c3353cb2..7da980f2 100644 --- a/pandora/edit/models.py +++ b/pandora/edit/models.py @@ -191,7 +191,7 @@ class Edit(models.Model): self.rightslevel = int(data['rightslevel']) if key == 'query' and not data['query']: setattr(self, key, {"static":True}) - elif key == 'query': + elif key == 'query' and isinstance(data[key], dict): setattr(self, key, data[key]) if 'position' in data: diff --git a/pandora/itemlist/models.py b/pandora/itemlist/models.py index 35ce6a3b..4b169c06 100644 --- a/pandora/itemlist/models.py +++ b/pandora/itemlist/models.py @@ -116,7 +116,7 @@ class List(models.Model): for key in data: if key == 'query' and not data['query']: setattr(self, key, {"static":True}) - elif key == 'query': + elif key == 'query' and isinstance(data[key], dict): setattr(self, key, data[key]) elif key == 'type': if data[key] == 'static': diff --git a/pandora/user/models.py b/pandora/user/models.py index 75f8b583..8401c8ff 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -116,7 +116,9 @@ class SessionData(models.Model): if data.ip.startswith('::ffff:'): data.ip = data.ip[len('::ffff:'):] data.useragent = request.META.get('HTTP_USER_AGENT', '')[:4096] - data.info = json.loads(request.POST.get('data', '{}')) + info = json.loads(request.POST.get('data', '{}')) + if info and isinstance(info, dict): + data.info = info screen = data.info.get('screen', {}) if screen and 'height' in screen and 'width' in screen: data.screensize = u'%s\xd7%s' % (screen['width'], screen['height'])