@@ -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