From 2c805bbeceb4482715916ed523b6bcaab8525b29 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 21 Oct 2015 16:00:31 +0100 Subject: [PATCH] More paranoia when handling responses --- lib/http-api.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/http-api.js b/lib/http-api.js index e192dfa91..09b3d4d38 100644 --- a/lib/http-api.js +++ b/lib/http-api.js @@ -111,6 +111,11 @@ module.exports.MatrixHttpApi.prototype = { case global.XMLHttpRequest.DONE: clearTimeout(xhr.timeout_timer); + if (!xhr.responseText) { + cb(new Error('No response body.')); + return; + } + var resp = JSON.parse(xhr.responseText); if (resp.content_uri === undefined) { cb(new Error('Bad response'));