[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
3beb4545c4.
opw-2702036
X-original-commit: 5dcf6e91fed769f4ab22ac63d3e5078cdd352e86
Part-of: odoo/odoo#82099
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user