Fix setting channel js/css

This commit is contained in:
Calvin Montgomery 2014-07-01 20:43:34 -07:00
parent 002dadd67a
commit 03ba657783

View file

@ -145,9 +145,14 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
if ("externalcss" in data && user.account.effectiveRank >= 3) { if ("externalcss" in data && user.account.effectiveRank >= 3) {
var link = (""+data.externalcss).substring(0, 255); var link = (""+data.externalcss).substring(0, 255);
if (!link) {
this.opts.externalcss = "";
return;
}
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";
@ -167,10 +172,14 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
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) {
this.opts.externaljs = "";
return;
}
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";