From 12447ce5dc0b78acc76383c8d7a3582c80244566 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Mon, 1 Sep 2014 20:33:11 -0500 Subject: [PATCH] Give up early if username is invalid for rank change --- lib/channel/ranks.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/channel/ranks.js b/lib/channel/ranks.js index 357d4014..2dbfdb02 100644 --- a/lib/channel/ranks.js +++ b/lib/channel/ranks.js @@ -35,7 +35,7 @@ RankModule.prototype.sendChannelRanks = function (users) { if (err) { return; } - + users.forEach(function (u) { if (u.account.effectiveRank >= 3) { u.socket.emit("channelRanks", ranks); @@ -70,6 +70,13 @@ RankModule.prototype.handleRankChange = function (user, data) { var userrank = user.account.effectiveRank; var name = data.name.substring(0, 20).toLowerCase(); + if (!name.match(/^[a-zA-Z0-9_-]{1,20}$/)) { + user.socket.emit("channelRankFail", { + msg: "Invalid target name " + data.name + }); + return; + } + if (isNaN(rank) || rank < 1 || (rank >= userrank && !(userrank === 4 && rank === 4))) { user.socket.emit("channelRankFail", { msg: "Updating user rank failed: You can't promote someone to a rank equal " +