diff --git a/lib/channel/opts.js b/lib/channel/opts.js index d2d4f67a..484d6247 100644 --- a/lib/channel/opts.js +++ b/lib/channel/opts.js @@ -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) { diff --git a/www/js/callbacks.js b/www/js/callbacks.js index 5cb15c1f..291e9a4f 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -249,14 +249,19 @@ Callbacks = { channelOpts: function(opts) { document.title = opts.pagetitle; PAGETITLE = opts.pagetitle; - $("#chanexternalcss").remove(); - if(opts.externalcss.trim() != "" && !USEROPTS.ignore_channelcss) { - $("") - .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(); + $("") + .attr("rel", "stylesheet") + .attr("href", opts.externalcss) + .attr("id", "chanexternalcss") + .appendTo($("head")); + } } if(opts.externaljs.trim() != "" && !USEROPTS.ignore_channeljs &&