Actually do filter safe paths, but allow any other domain

This commit is contained in:
Phoenix Eliot 2016-09-06 17:10:58 -07:00
parent b08c1af038
commit 6cbc6452fc

View file

@ -63,6 +63,8 @@ setupDomainFilterMiddleware = (app) ->
domainPrefix = req.host.match(domainRegex)?[1] or ''
if _.any(unsafePaths, (pathRegex) -> pathRegex.test(req.path)) and (req.host isnt domainPrefix + config.unsafeContentHostname)
res.redirect('http://' + domainPrefix + config.unsafeContentHostname + req.path)
else if not _.any(unsafePaths, (pathRegex) -> pathRegex.test(req.path)) and req.host is domainPrefix + config.unsafeContentHostname
res.redirect('http://' + domainPrefix + config.mainHostname + req.path)
else
next()