diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2025-02-13 18:06:43 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2025-02-17 15:24:07 +0100 |
commit | 579a337750c85bab1f1e6d798c10cbb012f3f819 (patch) | |
tree | 0d246a2c6df3f97676e8158865bb02154303b27b /lib | |
parent | 509a53c36c485f8232b1d173f7aa0f7e8bfe9eb2 (diff) | |
download | nextcloud-server-579a337750c85bab1f1e6d798c10cbb012f3f819.tar.gz nextcloud-server-579a337750c85bab1f1e6d798c10cbb012f3f819.zip |
fix: Fix psalm taint error in L10N factory
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/L10N/Factory.php | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php index eb84f264f5f..5645693f8d9 100644 --- a/lib/private/L10N/Factory.php +++ b/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); @@ -131,6 +129,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 * * @param string|null $appId App id or null for core |