summaryrefslogtreecommitdiff
path: root/odoo/http.py
diff options
context:
space:
mode:
authorOlivier Dony <odo@odoo.com>2019-09-06 11:02:43 +0200
committerOlivier Dony <odo@odoo.com>2019-09-28 03:54:54 +0200
commitcc6c0c8b21a8f577ab9d48708ce4a9655d326e50 (patch)
tree909c70d24755463ce46aa89d47292059f979245f /odoo/http.py
parent60f9c85a8c553e68dc6df30347511ba495af9945 (diff)
[IMP] http: remove outdated logic for redirects
Section 7.1.2 of RFC 7231 requires preservation of URL fragment through redirects. Our old JS redirection code was necessary when browsers did not consistently implement it. Apart from a few odd and marginal exceptions they all do it now, so we can stop that.
Diffstat (limited to 'odoo/http.py')
-rw-r--r--odoo/http.py25
1 files changed, 7 insertions, 18 deletions
diff --git a/odoo/http.py b/odoo/http.py
index a332baeadb2..94445401801 100644
--- a/odoo/http.py
+++ b/odoo/http.py
@@ -161,31 +161,20 @@ def dispatch_rpc(service_name, method, params):
raise
def local_redirect(path, query=None, keep_hash=False, code=303):
+ # FIXME: drop the `keep_hash` param, now useless
url = path
if not query:
query = {}
if query:
url += '?' + werkzeug.url_encode(query)
- if keep_hash:
- return redirect_with_hash(url, code)
- else:
- return werkzeug.utils.redirect(url, code)
+ return werkzeug.utils.redirect(url, code)
def redirect_with_hash(url, code=303):
- # Most IE and Safari versions decided not to preserve location.hash upon
- # redirect. And even if IE10 pretends to support it, it still fails
- # inexplicably in case of multiple redirects (and we do have some).
- # 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)
- # FIXME: decide whether urls should be bytes or text, apparently
- # addons/website/controllers/main.py:91 calls this with a bytes url
- # but addons/web/controllers/main.py:481 uses text... (blows up on login)
- url = pycompat.to_text(url).strip()
- if urls.url_parse(url, scheme='http').scheme not in ('http', 'https'):
- url = u'http://' + url
- url = url.replace("'", "%27").replace("<", "%3C")
- return "<html><head><script>window.location = '%s' + location.hash;</script></head></html>" % url
+ # Section 7.1.2 of RFC 7231 requires preservation of URL fragment through redirects,
+ # so we don't need any special handling anymore. This function could be dropped in the future.
+ # seealso : http://www.rfc-editor.org/info/rfc7231
+ # https://tools.ietf.org/html/rfc7231#section-7.1.2
+ return werkzeug.utils.redirect(url, code)
class WebRequest(object):
""" Parent class for all Odoo Web request types, mostly deals with