From 4588e52120bf89fea05a79517411c6fa6bd2ff63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 5 Sep 2020 18:30:39 -0400 Subject: [PATCH] fix: allow setting maximumAboutMeLength to 0 --- src/meta/configs.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/meta/configs.js b/src/meta/configs.js index c8794916d1..55cdfaa42c 100644 --- a/src/meta/configs.js +++ b/src/meta/configs.js @@ -172,10 +172,10 @@ Configs.cookie = { }; async function processConfig(data) { - ensurePositiveInteger(data, 'maximumUsernameLength'); - ensurePositiveInteger(data, 'minimumUsernameLength'); - ensurePositiveInteger(data, 'minimumPasswordLength'); - ensurePositiveInteger(data, 'maximumAboutMeLength'); + ensureInteger(data, 'maximumUsernameLength', 1); + ensureInteger(data, 'minimumUsernameLength', 1); + ensureInteger(data, 'minimumPasswordLength', 1); + ensureInteger(data, 'maximumAboutMeLength', 0); if (data.minimumUsernameLength > data.maximumUsernameLength) { throw new Error('[[error:invalid-data]]'); } @@ -186,10 +186,10 @@ async function processConfig(data) { ]); } -function ensurePositiveInteger(data, field) { +function ensureInteger(data, field, min) { if (data.hasOwnProperty(field)) { data[field] = parseInt(data[field], 10); - if (!(data[field] > 0)) { + if (!(data[field] >= min)) { throw new Error('[[error:invalid-data]]'); } }