From 6a5ab1ff87a9eefb899fb35501bf9cf3d437acd8 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 14 Aug 2019 17:34:08 +0200 Subject: [PATCH] update 'isNewChannel' --- rpc.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rpc.js b/rpc.js index 33f60a902..37418b93f 100644 --- a/rpc.js +++ b/rpc.js @@ -1475,8 +1475,10 @@ var removeLoginBlock = function (Env, msg, cb) { }); }; -// FIXME METADATA +var ARRAY_LINE = /^\[/; + // since we're changing how metadata works this can lead to false positives +// XXX rewrite this such that we can abort once we have a conclusive answer var isNewChannel = function (Env, channel, cb) { if (!isValidId(channel)) { return void cb('INVALID_CHAN'); } if (channel.length !== 32) { return void cb('INVALID_CHAN'); } @@ -1487,6 +1489,12 @@ var isNewChannel = function (Env, channel, cb) { if (done) { return; } var parsed; try { + if (count === 0 && typeof(msg) === 'string' && ARRAY_LINE.test(msg)) { + done = true; + count++; + return void cb(void 0, false); + } + parsed = JSON.parse(msg); if (parsed && typeof(parsed) === 'object') { count++; } if (count >= 2) {