From 4e24115a315b4c1451cd08640c638f7cfbc93d69 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 20 Dec 2021 15:56:26 +0000 Subject: [PATCH] [FIX] http_routing: redirect no double query_string Reproduction: - have 308 redirection from /shop to /boutique and refresh routes - go in incognito on /boutique?order=name+asc (don't go on /boutique first, or restart odoo to clear ORM cache) - select a sorting option eg. price => we are redirected to /boutique?order=name+asc?order=list_price+asc and this error is shown: Invalid "order" specified (is_published desc, name asc?order=list_price asc, id desc). This is happening because url_rewrite is keeping current query string (see ir.http()._slug_matching) and caching it. So if the first call caches: url_rewrite('/boutique') => /boutique?order=name+asc all other url_rewrite('/boutique') calls will give you /boutique?order=name+asc even if the query string has changed. In addition to that, url_for may append query_string to url_rewrite return value, so you may get a double query_string such as: ?order=name+asc?order=list_price+asc which causes the error. In this fix, we restore the removal of query string that was removed in 3beb4545c4599469eff77a247db12b630cace754. opw-2702036 X-original-commit: 5dcf6e91fed769f4ab22ac63d3e5078cdd352e86 Part-of: odoo/odoo#82099 --- addons/http_routing/models/ir_http.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/http_routing/models/ir_http.py b/addons/http_routing/models/ir_http.py index 6471b132d48..54be2a76ffd 100644 --- a/addons/http_routing/models/ir_http.py +++ b/addons/http_routing/models/ir_http.py @@ -661,7 +661,8 @@ class IrHttp(models.AbstractModel): except werkzeug.exceptions.MethodNotAllowed: endpoint = router.match(path, method='GET', query_args=query_args) except werkzeug.routing.RequestRedirect as e: - new_url = e.new_url[7:] # remove scheme + # get path from http://{path}?{current query string} + new_url = e.new_url.split('?')[0][7:] _, endpoint = self.url_rewrite(new_url, query_args) endpoint = endpoint and [endpoint] except werkzeug.exceptions.NotFound: