Check that username and password are present.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
Daniel Kesselberg 2020-02-23 18:53:17 +01:00
parent baf386b5d8
commit 56efd687ab
No known key found for this signature in database
GPG key ID: 36E3664E099D0614

View file

@ -1077,10 +1077,12 @@ class OC {
); );
foreach ($vars as $var) { foreach ($vars as $var) {
if (isset($_SERVER[$var]) && preg_match('/Basic\s+(.*)$/i', $_SERVER[$var], $matches)) { if (isset($_SERVER[$var]) && preg_match('/Basic\s+(.*)$/i', $_SERVER[$var], $matches)) {
list($name, $password) = explode(':', base64_decode($matches[1]), 2); $credentials = explode(':', base64_decode($matches[1]), 2);
$_SERVER['PHP_AUTH_USER'] = $name; if (count($credentials) === 2) {
$_SERVER['PHP_AUTH_PW'] = $password; $_SERVER['PHP_AUTH_USER'] = $credentials[0];
break; $_SERVER['PHP_AUTH_PW'] = $credentials[1];
break;
}
} }
} }
} }