From 4e2c697abcb893fc6da401de215e255ff301357c Mon Sep 17 00:00:00 2001 From: David Snopek Date: Thu, 1 Aug 2013 17:29:19 +0100 Subject: [PATCH] Fix for a JSON encoding "quirk" in PHP --- AnkiServer/apps/rest_app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/AnkiServer/apps/rest_app.py b/AnkiServer/apps/rest_app.py index 58d01f8..efd8452 100644 --- a/AnkiServer/apps/rest_app.py +++ b/AnkiServer/apps/rest_app.py @@ -228,6 +228,10 @@ class RestApp(object): logging.error(req.path+': Unable to parse JSON: '+str(e), exc_info=True) raise HTTPBadRequest() + # fix for a JSON encoding 'quirk' in PHP + if type(data) == list and len(data) == 0: + data = {} + # make the keys into non-unicode strings data = dict([(str(k), v) for k, v in data.items()]) @@ -553,7 +557,7 @@ class CollectionHandler(RestHandlerBase): args = [] if req.data.has_key('updated_since'): sql += ' WHERE r.id > ?' - args.append(req.data['updated_since'] * 1000) + args.append(long(req.data['updated_since']) * 1000) sql += ' ORDER BY r.id DESC' sql += ' LIMIT ' + str(req.data.get('limit', 100))