Browse Source

Merge pull request #277 from matrix-org/babolivier/unbind_parse

Parse JSON as string, not bytes
Brendan Abolivier 4 years ago
parent
commit
dfb62c8064
1 changed files with 2 additions and 1 deletions
  1. 2 1
      sydent/http/servlets/threepidunbindservlet.py

+ 2 - 1
sydent/http/servlets/threepidunbindservlet.py

@@ -50,7 +50,8 @@ class ThreePidUnbindServlet(Resource):
     def _async_render_POST(self, request):
         try:
             try:
-                body = json.load(request.content)
+                # json.loads doesn't allow bytes in Python 3.5
+                body = json.loads(request.content.read().decode("UTF-8"))
             except ValueError:
                 request.setResponseCode(400)
                 request.write(dict_to_json_bytes({'errcode': 'M_BAD_JSON', 'error': 'Malformed JSON'}))