[FIX] http: force protocol when missing in URL

This commit is contained in:
Olivier Dony 2017-06-14 16:29:55 +02:00
parent eb8d919015
commit d655824028
No known key found for this signature in database
GPG Key ID: CD556E25E8A6D0D4
1 changed files with 2 additions and 0 deletions

View File

@ -160,6 +160,8 @@ def redirect_with_hash(url, code=303):
# See extensive test page at http://greenbytes.de/tech/tc/httpredirects/
if request.httprequest.user_agent.browser in ('firefox',):
return werkzeug.utils.redirect(url, code)
if urlparse.urlparse(url, scheme='http').scheme not in ('http', 'https'):
url = 'http://' + url
url = url.replace("'", "%27").replace("<", "%3C")
return "<html><head><script>window.location = '%s' + location.hash;</script></head></html>" % url