@@ -108,9 +108,7 @@ public function get($app, $lang = null, $locale = null) {
108
108
$ locale = $ forceLocale ;
109
109
}
110
110
111
- if ($ lang === null || !$ this ->languageExists ($ app , $ lang )) {
112
- $ lang = $ this ->findLanguage ($ app );
113
- }
111
+ $ lang = $ this ->validateLanguage ($ app , $ lang );
114
112
115
113
if ($ locale === null || !$ this ->localeExists ($ locale )) {
116
114
$ locale = $ this ->findLocale ($ lang );
@@ -130,6 +128,29 @@ public function get($app, $lang = null, $locale = null) {
130
128
});
131
129
}
132
130
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
+
133
154
/**
134
155
* Find the best language
135
156
*
0 commit comments