[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) <rde@odoo.com>
This commit is contained in:
Huy
2022-04-19 18:39:55 +02:00
committed by Romain Derie
parent a74f159af2
commit 76ee79749a
+3 -1
View File
@@ -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: