Fixes at Xaekai's request

This commit is contained in:
calzoneman 2014-08-27 18:45:11 -05:00
parent c8684d58ed
commit 7b00ba10b9
2 changed files with 48 additions and 44 deletions

View file

@ -148,54 +148,53 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
var link = (""+data.externalcss).substring(0, 255); var link = (""+data.externalcss).substring(0, 255);
if (!link) { if (!link) {
this.opts.externalcss = ""; this.opts.externalcss = "";
return; } else {
} try {
var data = url.parse(link);
try { if (!data.protocol || !data.protocol.match(/^(https?|ftp):/)) {
var data = url.parse(link); throw "Unacceptable protocol " + data.protocol;
if (!data.protocol || !data.protocol.match(/^(https?|ftp):/)) { } else if (!data.host) {
throw "Unacceptable protocol " + data.protocol; throw "URL is missing host";
} else if (!data.host) { } else {
throw "URL is missing host"; link = data.href;
} else { }
link = data.href; } catch (e) {
user.socket.emit("errorMsg", {
msg: "Invalid URL for external CSS: " + e,
alert: true
});
return;
} }
} catch (e) {
user.socket.emit("errorMsg", {
msg: "Invalid URL for external CSS: " + e,
alert: true
});
return;
}
this.opts.externalcss = link; this.opts.externalcss = link;
}
} }
if ("externaljs" in data && user.account.effectiveRank >= 3) { if ("externaljs" in data && user.account.effectiveRank >= 3) {
var link = (""+data.externaljs).substring(0, 255); var link = (""+data.externaljs).substring(0, 255);
if (!link) { if (!link) {
this.opts.externaljs = ""; this.opts.externaljs = "";
return; } else {
}
try { try {
var data = url.parse(link); var data = url.parse(link);
if (!data.protocol || !data.protocol.match(/^(https?|ftp):/)) { if (!data.protocol || !data.protocol.match(/^(https?|ftp):/)) {
throw "Unacceptable protocol " + data.protocol; throw "Unacceptable protocol " + data.protocol;
} else if (!data.host) { } else if (!data.host) {
throw "URL is missing host"; throw "URL is missing host";
} else { } else {
link = data.href; link = data.href;
}
} catch (e) {
user.socket.emit("errorMsg", {
msg: "Invalid URL for external JS: " + e,
alert: true
});
return;
} }
} catch (e) {
user.socket.emit("errorMsg", {
msg: "Invalid URL for external JS: " + e,
alert: true
});
return;
}
this.opts.externaljs = link; this.opts.externaljs = link;
}
} }
if ("chat_antiflood" in data) { if ("chat_antiflood" in data) {

View file

@ -249,14 +249,19 @@ Callbacks = {
channelOpts: function(opts) { channelOpts: function(opts) {
document.title = opts.pagetitle; document.title = opts.pagetitle;
PAGETITLE = opts.pagetitle; PAGETITLE = opts.pagetitle;
$("#chanexternalcss").remove();
if(opts.externalcss.trim() != "" && !USEROPTS.ignore_channelcss) { if (!USEROPTS.ignore_channelcss &&
$("<link/>") opts.externalcss !== CHANNEL.opts.externalcss) {
.attr("rel", "stylesheet") $("#chanexternalcss").remove();
.attr("href", opts.externalcss)
.attr("id", "chanexternalcss") if (opts.externalcss.trim() !== "") {
.appendTo($("head")); $("#chanexternalcss").remove();
$("<link/>")
.attr("rel", "stylesheet")
.attr("href", opts.externalcss)
.attr("id", "chanexternalcss")
.appendTo($("head"));
}
} }
if(opts.externaljs.trim() != "" && !USEROPTS.ignore_channeljs && if(opts.externaljs.trim() != "" && !USEROPTS.ignore_channeljs &&