From 51e1b9b0436015ab6a630a6b067bfe038f6146d0 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 7 Oct 2020 16:31:49 +0200 Subject: [PATCH] Fix custom limit not applied when using a raw edPublic --- lib/commands/quota.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/commands/quota.js b/lib/commands/quota.js index d35aa463d..dbaf9efbb 100644 --- a/lib/commands/quota.js +++ b/lib/commands/quota.js @@ -37,13 +37,24 @@ Quota.applyCustomLimits = function (Env) { var limits = {}; Object.keys(custom).forEach(function (k) { var user; - try { - user = Keys.parseUser(k); - } catch (err) { - return void Env.Log.error("PARSE_CUSTOM_LIMIT_BLOCK", { - user: k, - error: err.message, - }); + + // XXX this length (44) is also hardcoded in decrees.js + // before calling Keys.parseUser. + // Maybe we should improve Keys.parseUser to handle this + // option directly + if (k.length === 44) { + user = { + pubkey: Util.unescapeKeyCharacters(k) + } + } else { + try { + user = Keys.parseUser(k); + } catch (err) { + return void Env.Log.error("PARSE_CUSTOM_LIMIT_BLOCK", { + user: k, + error: err.message, + }); + } } var unsafeKey = user.pubkey;