From 7b92145f7c85acb80b56e1dcf8bb5dc7125fcf9f Mon Sep 17 00:00:00 2001 From: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com> Date: Wed, 25 Feb 2026 15:25:03 +0100 Subject: [PATCH] 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> --- lib/private/L10N/Factory.php | 2 +- tests/lib/L10N/FactoryTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php index 993add47781b2..9a8c9e690f88c 100644 --- a/lib/private/L10N/Factory.php +++ b/lib/private/L10N/Factory.php @@ -146,7 +146,7 @@ private function cleanLanguage(?string $lang): ?string { 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); } diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php index 9df113dee36e5..1084558bceb54 100644 --- a/tests/lib/L10N/FactoryTest.php +++ b/tests/lib/L10N/FactoryTest.php @@ -94,6 +94,7 @@ public static function dataCleanLanguage(): array { 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'], ];