[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) <odo@openerp.com>
This commit is contained in:
Romain Derie
2019-09-30 14:04:07 +00:00
parent 8d7004b5d4
commit 3408c4dd1e
+3 -3
View File
@@ -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):