check data is a dict

This commit is contained in:
j 2016-02-19 18:46:53 +05:30
commit d241b90b63
4 changed files with 6 additions and 4 deletions

View file

@ -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'])