Skip to content

Commit 7d26ac8

Browse files
committed
fix: Fix psalm taint error in L10N factory
Signed-off-by: Côme Chilliet <[email protected]>
1 parent b003af2 commit 7d26ac8

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

lib/private/L10N/Factory.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ public function get($app, $lang = null, $locale = null) {
108108
$locale = $forceLocale;
109109
}
110110

111-
if ($lang === null || !$this->languageExists($app, $lang)) {
112-
$lang = $this->findLanguage($app);
113-
}
111+
$lang = $this->validateLanguage($app, $lang);
114112

115113
if ($locale === null || !$this->localeExists($locale)) {
116114
$locale = $this->findLocale($lang);
@@ -130,6 +128,29 @@ public function get($app, $lang = null, $locale = null) {
130128
});
131129
}
132130

131+
/**
132+
* Check that $lang is an existing language and not null, otherwise return the language to use instead
133+
*
134+
* @psalm-taint-escape callable
135+
* @psalm-taint-escape cookie
136+
* @psalm-taint-escape file
137+
* @psalm-taint-escape has_quotes
138+
* @psalm-taint-escape header
139+
* @psalm-taint-escape html
140+
* @psalm-taint-escape include
141+
* @psalm-taint-escape ldap
142+
* @psalm-taint-escape shell
143+
* @psalm-taint-escape sql
144+
* @psalm-taint-escape unserialize
145+
*/
146+
private function validateLanguage(string $app, ?string $lang): string {
147+
if ($lang === null || !$this->languageExists($app, $lang)) {
148+
return $this->findLanguage($app);
149+
} else {
150+
return $lang;
151+
}
152+
}
153+
133154
/**
134155
* Find the best language
135156
*

0 commit comments

Comments
 (0)