Skip to content

Commit 9851792

Browse files
authored
Merge pull request #58573 from nextcloud/backport/58571/stable31
[stable31] fix(L10N): stop stripping _ from language codes
2 parents 14ba817 + 7b92145 commit 9851792

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

lib/private/L10N/Factory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private function cleanLanguage(?string $lang): ?string {
146146
if ($lang === null) {
147147
return null;
148148
}
149-
$lang = preg_replace('/[^a-zA-Z0-9.;,=-]/', '', $lang);
149+
$lang = preg_replace('/[^a-zA-Z0-9.;,=_-]/', '', $lang);
150150
return str_replace('..', '', $lang);
151151
}
152152

tests/lib/L10N/FactoryTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public static function dataCleanLanguage(): array {
9494
return [
9595
'null shortcut' => [null, null],
9696
'default language' => ['de', 'de'],
97+
'regional language' => ['de_DE', 'de_DE'],
9798
'malicious language' => ['de/../fr', 'defr'],
9899
'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'],
99100
];

0 commit comments

Comments
 (0)