fix(L10N): stop stripping _ from language codes

Stripping the underscore breaks support for all languages like de_AT,
de_DE and so on...

Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
This commit is contained in:
Salvatore Martire 2026-02-25 15:25:03 +01:00 committed by backportbot[bot]
parent 14ba817034
commit 7b92145f7c
2 changed files with 2 additions and 1 deletions

View file

@ -146,7 +146,7 @@ class Factory implements IFactory {
if ($lang === null) {
return null;
}
$lang = preg_replace('/[^a-zA-Z0-9.;,=-]/', '', $lang);
$lang = preg_replace('/[^a-zA-Z0-9.;,=_-]/', '', $lang);
return str_replace('..', '', $lang);
}

View file

@ -94,6 +94,7 @@ class FactoryTest extends TestCase {
return [
'null shortcut' => [null, null],
'default language' => ['de', 'de'],
'regional language' => ['de_DE', 'de_DE'],
'malicious language' => ['de/../fr', 'defr'],
'request language' => ['kab;q=0.8,ka;q=0.7,de;q=0.6', 'kab;q=0.8,ka;q=0.7,de;q=0.6'],
];