From 942a136886bfd84dba174fad0e2fcbe183825da0 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 15 Jun 2021 03:52:12 +0530 Subject: [PATCH] somewhat stricter httpUnsafeOrigin validation --- server.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 72779c5f5..848167a98 100644 --- a/server.js +++ b/server.js @@ -24,8 +24,8 @@ var fancyURL = function (domain, path) { }; (function () { - // you absolutely must provide an 'httpUnsafeOrigin' - if (typeof(Env.httpUnsafeOrigin) !== 'string') { + // you absolutely must provide an 'httpUnsafeOrigin' (a truthy string) + if (!Env.httpUnsafeOrigin || typeof(Env.httpUnsafeOrigin) !== 'string') { throw new Error("No 'httpUnsafeOrigin' provided"); } @@ -66,7 +66,7 @@ var setHeaders = (function () { } // next define the base Content Security Policy (CSP) headers - if (typeof(config.contentSecurity) === 'string') { // XXX deprecate this + if (typeof(config.contentSecurity) === 'string') { headers['Content-Security-Policy'] = config.contentSecurity; if (!/;$/.test(headers['Content-Security-Policy'])) { headers['Content-Security-Policy'] += ';' } if (headers['Content-Security-Policy'].indexOf('frame-ancestors') === -1) {