Reject blank emote names and images
This commit is contained in:
parent
889fb6595f
commit
11d4c4ca62
|
@ -79,6 +79,10 @@ function validateEmote(f) {
|
||||||
s = "(^|\\s)" + s + "(?!\\S)";
|
s = "(^|\\s)" + s + "(?!\\S)";
|
||||||
f.source = s;
|
f.source = s;
|
||||||
|
|
||||||
|
if (!f.image || !f.name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new RegExp(f.source, "gi");
|
new RegExp(f.source, "gi");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -140,6 +144,16 @@ EmoteModule.prototype.handleUpdateEmote = function (user, data) {
|
||||||
|
|
||||||
var f = validateEmote(data);
|
var f = validateEmote(data);
|
||||||
if (!f) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2561,8 +2561,12 @@ function formatUserPlaylistList() {
|
||||||
function loadEmotes(data) {
|
function loadEmotes(data) {
|
||||||
CHANNEL.emotes = [];
|
CHANNEL.emotes = [];
|
||||||
data.forEach(function (e) {
|
data.forEach(function (e) {
|
||||||
e.regex = new RegExp(e.source, "gi");
|
if (e.image && e.name) {
|
||||||
CHANNEL.emotes.push(e);
|
e.regex = new RegExp(e.source, "gi");
|
||||||
|
CHANNEL.emotes.push(e);
|
||||||
|
} else {
|
||||||
|
console.error("Rejecting invalid emote: " + JSON.stringify(e));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue