Skip to content

Commit

Permalink
fix: Fix psalm taint error in L10N factory
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Feb 13, 2025
1 parent b003af2 commit 7d26ac8
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions lib/private/L10N/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ public function get($app, $lang = null, $locale = null) {
$locale = $forceLocale;
}

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

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

/**
* Check that $lang is an existing language and not null, otherwise return the language to use instead
*
* @psalm-taint-escape callable
* @psalm-taint-escape cookie
* @psalm-taint-escape file
* @psalm-taint-escape has_quotes
* @psalm-taint-escape header
* @psalm-taint-escape html
* @psalm-taint-escape include
* @psalm-taint-escape ldap
* @psalm-taint-escape shell
* @psalm-taint-escape sql
* @psalm-taint-escape unserialize
*/
private function validateLanguage(string $app, ?string $lang): string {
if ($lang === null || !$this->languageExists($app, $lang)) {
return $this->findLanguage($app);
} else {
return $lang;
}
}

/**
* Find the best language
*
Expand Down

0 comments on commit 7d26ac8

Please sign in to comment.