Require user permission to run channel js

This commit is contained in:
Calvin Montgomery 2014-07-01 20:11:54 -07:00
parent 3661ab1fd9
commit e87ddb473b
8 changed files with 232 additions and 32 deletions

View file

@ -1,6 +1,7 @@
var ChannelModule = require("./module");
var Config = require("../config");
var Utilities = require("../utilities");
var url = require("url");
function OptionsModule(channel) {
ChannelModule.apply(this, arguments);
@ -143,11 +144,48 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
}
if ("externalcss" in data && user.account.effectiveRank >= 3) {
this.opts.externalcss = (""+data.externalcss).substring(0, 255);
var link = (""+data.externalcss).substring(0, 255);
try {
var data = url.parse(link);
if (!data.protocol || !data.protocol.match(/^(https?|ftp):$/)) {
throw "Unacceptable protocol " + data.protocol;
} else if (!data.host) {
throw "URL is missing host";
} else {
link = data.href;
}
} catch (e) {
user.socket.emit("errorMsg", {
msg: "Invalid URL for external CSS: " + e,
alert: true
});
return;
}
this.opts.externalcss = link;
}
if ("externaljs" in data && user.account.effectiveRank >= 3) {
this.opts.externaljs = (""+data.externaljs).substring(0, 255);
var link = (""+data.externaljs).substring(0, 255);
try {
var data = url.parse(link);
if (!data.protocol || !data.protocol.match(/^(https?|ftp)$/)) {
throw "Unacceptable protocol " + data.protocol;
} else if (!data.host) {
throw "URL is missing host";
} else {
link = data.href;
}
} catch (e) {
user.socket.emit("errorMsg", {
msg: "Invalid URL for external JS: " + e,
alert: true
});
return;
}
this.opts.externaljs = link;
}
if ("chat_antiflood" in data) {

View file

@ -270,16 +270,16 @@ PlaylistModule.prototype.sendChangeMedia = function (users) {
if (users === this.channel.users) {
this.channel.broadcastAll("setCurrent", uid);
this.channel.broadcastAll("changeMedia", update);
var m = this.current.media;
this.channel.logger.log("[playlist] Now playing: " + m.title +
" (" + m.type + ":" + m.id + ")");
} else {
users.forEach(function (u) {
u.socket.emit("setCurrent", uid);
u.socket.emit("changeMedia", update);
});
}
var m = this.current.media;
this.channel.logger.log("[playlist] Now playing: " + m.title +
" (" + m.type + ":" + m.id + ")");
};
PlaylistModule.prototype.sendMediaUpdate = function (users) {