diff --git a/lib/channel/opts.js b/lib/channel/opts.js index f3a0dc49..84950c83 100644 --- a/lib/channel/opts.js +++ b/lib/channel/opts.js @@ -145,9 +145,14 @@ OptionsModule.prototype.handleSetOptions = function (user, data) { if ("externalcss" in data && user.account.effectiveRank >= 3) { 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):$/)) { + if (!data.protocol || !data.protocol.match(/^(https?|ftp):/)) { throw "Unacceptable protocol " + data.protocol; } else if (!data.host) { throw "URL is missing host"; @@ -167,10 +172,14 @@ OptionsModule.prototype.handleSetOptions = function (user, data) { if ("externaljs" in data && user.account.effectiveRank >= 3) { var link = (""+data.externaljs).substring(0, 255); + if (!link) { + this.opts.externaljs = ""; + return; + } try { 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; } else if (!data.host) { throw "URL is missing host";