From 76ee79749a36f31498a06fe3e9ff4a27c7347f1d Mon Sep 17 00:00:00 2001 From: Huy Date: Thu, 7 Apr 2022 09:56:24 +0000 Subject: [PATCH] [FIX] website_forum: avoid error when the sort param is encoded Currently, when accessing a URL with a sorting encoded value, the system will raise an error with a specific message, which feels unfriendly to the user as well as saves unnecessary logs in the log file. So we decoded that value, if except then sort a page without sorting. closes odoo/odoo#89072 X-original-commit: 33356fcc9867ee23fee2a032dcca7daea1ada4c5 Signed-off-by: Romain Derie (rde) --- addons/website_forum/controllers/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index e5951198855..0d93d062fce 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -17,6 +17,7 @@ from odoo.addons.website.models.ir_http import sitemap_qs2dom from odoo.addons.website_profile.controllers.main import WebsiteProfile from odoo.addons.portal.controllers.portal import _build_url_w_params +from odoo.exceptions import UserError from odoo.http import request _logger = logging.getLogger(__name__) @@ -107,8 +108,9 @@ class WebsiteForum(WebsiteProfile): # check that sorting is valid # retro-compatibily for V8 and google links try: + sorting = werkzeug.urls.url_unquote_plus(sorting) Post._generate_order_by(sorting, None) - except ValueError: + except (UserError, ValueError): sorting = False if not sorting: