fix: Fix psalm taint error in L10N factory

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/50800/head
Côme Chilliet 8 months ago
parent 509a53c36c
commit 579a337750
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
  1. 27
      lib/private/L10N/Factory.php

@ -108,9 +108,7 @@ class Factory implements IFactory {
$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);
@ -130,6 +128,29 @@ class Factory implements IFactory {
});
}
/**
* 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
*

Loading…
Cancel
Save