Skip to content

Commit a118ce8

Browse files
authored
Merge pull request dokuwiki#4416 from dokuwiki/getallheaders
treat getallheaders more suspiciously. fixes dokuwiki#4415
2 parents 3ab4aa6 + 0a30275 commit a118ce8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

inc/auth.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,18 @@ function auth_tokenlogin()
190190
global $auth;
191191
if (!$auth) return false;
192192

193-
// get the headers, either from Apache or from $_SERVER
193+
$headers = [];
194+
195+
// try to get the headers from Apache
194196
if (function_exists('getallheaders')) {
195-
$headers = array_change_key_case(getallheaders());
196-
} else {
197-
$headers = [];
197+
$headers = getallheaders();
198+
if (is_array($headers)) {
199+
$headers = array_change_key_case($headers);
200+
}
201+
}
202+
203+
// get the headers from $_SERVER
204+
if (!$headers) {
198205
foreach ($_SERVER as $key => $value) {
199206
if (substr($key, 0, 5) === 'HTTP_') {
200207
$headers[strtolower(substr($key, 5))] = $value;

0 commit comments

Comments
 (0)