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);
if (!link) {
this.opts.externalcss = "";
return;
}
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;
} else {
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;
}
} 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) {
var link = (""+data.externaljs).substring(0, 255);
if (!link) {
this.opts.externaljs = "";
return;
}
} else {
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;
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;
}
} 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) {

View File

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