From 11d4c4ca62fc2a24299b8a792ed918fb6f5bb72b Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 5 Dec 2015 18:52:39 -0800 Subject: [PATCH] Reject blank emote names and images --- src/channel/emotes.js | 14 ++++++++++++++ www/js/util.js | 8 ++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/channel/emotes.js b/src/channel/emotes.js index f6f70f54..3cf57737 100644 --- a/src/channel/emotes.js +++ b/src/channel/emotes.js @@ -79,6 +79,10 @@ function validateEmote(f) { s = "(^|\\s)" + s + "(?!\\S)"; f.source = s; + if (!f.image || !f.name) { + return false; + } + try { new RegExp(f.source, "gi"); } catch (e) { @@ -140,6 +144,16 @@ EmoteModule.prototype.handleUpdateEmote = function (user, data) { var f = validateEmote(data); if (!f) { + var message = "Unable to update emote '" + JSON.stringify(data) + "'. " + + "Please contact an administrator for assistance."; + if (!data.image || !data.name) { + message = "Emote names and images must not be blank."; + } + + user.socket.emit("errorMsg", { + msg: message, + alert: true + }); return; } diff --git a/www/js/util.js b/www/js/util.js index 979e0d6b..7ddfa1fd 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -2561,8 +2561,12 @@ function formatUserPlaylistList() { function loadEmotes(data) { CHANNEL.emotes = []; data.forEach(function (e) { - e.regex = new RegExp(e.source, "gi"); - CHANNEL.emotes.push(e); + if (e.image && e.name) { + e.regex = new RegExp(e.source, "gi"); + CHANNEL.emotes.push(e); + } else { + console.error("Rejecting invalid emote: " + JSON.stringify(e)); + } }); }