From 3408c4dd1eb197bdded6e87577ff71d7ffeca267 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 27 Sep 2019 10:34:38 +0000 Subject: [PATCH] [FIX] http_routing: restrict lang matching to installed lang When accessing an URL, there is some computation to check if you try to access a lang. Part of this job is to get the closest language available. For instance, you could try to get `/fr_BE/..` and it would redirect to `/fr_FR/..` if french is installed but not belgian french. There is a known issue when loading files/assets from a module starting by the same letter than a lang, in debug assets. Only reported case was `hr_XXX` modules which would be redirected to `hr_HR` lang (croatian). So, the issue would only occur when: 1. Debug assets is enabled 2. hr_HR lang is activated 3. only hr_XX modules would be impacted But since 269aa59411, the issue would appear even if `hr_HR` was not activated. This commit restore the issue to its minimal case, when `hr_HR` lang is activated. closes odoo/odoo#37494 Signed-off-by: Olivier Dony (odo) --- addons/http_routing/models/ir_http.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/http_routing/models/ir_http.py b/addons/http_routing/models/ir_http.py index 8ed7527232c..78217881e65 100644 --- a/addons/http_routing/models/ir_http.py +++ b/addons/http_routing/models/ir_http.py @@ -302,11 +302,11 @@ class IrHttp(models.AbstractModel): """ Try to find a similar lang. Eg: fr_BE and fr_FR :param lang_code: the lang `code` (en_US) """ - short_match = False if not lang_code: - return short_match + return False + short_match = False short = lang_code.partition('_')[0] - for code in [code for code, _, _ in request.env['res.lang'].get_available()]: + for (code, _) in request.env['res.lang'].get_installed(): if code == lang_code: return code if not short_match and code.startswith(short):