[FIX] base: fix broken URLs when redirecting
Similarly to werkzeug.urls.url_fix(), attempt to correct some leftover special characters that should have been URL-encoded. We cannot actually use `werkzeug.urls.url_fix` or `werkzeug.urls.url_quote`, as they expect more/most characters to be un-encoded. We have many existing cases where the redirect URL is already fully encoded or mostly encoded, and those functions would cause double-encoding, breaking the final URL.
This commit is contained in:
parent
8596a4ccaa
commit
43cff22950
|
@ -160,6 +160,7 @@ def redirect_with_hash(url, code=303):
|
||||||
# See extensive test page at http://greenbytes.de/tech/tc/httpredirects/
|
# See extensive test page at http://greenbytes.de/tech/tc/httpredirects/
|
||||||
if request.httprequest.user_agent.browser in ('firefox',):
|
if request.httprequest.user_agent.browser in ('firefox',):
|
||||||
return werkzeug.utils.redirect(url, code)
|
return werkzeug.utils.redirect(url, code)
|
||||||
|
url = url.replace("'", "%27").replace("<", "%3C")
|
||||||
return "<html><head><script>window.location = '%s' + location.hash;</script></head></html>" % url
|
return "<html><head><script>window.location = '%s' + location.hash;</script></head></html>" % url
|
||||||
|
|
||||||
class WebRequest(object):
|
class WebRequest(object):
|
||||||
|
|
Loading…
Reference in New Issue