[BUGFIX] Prevent call getHeader() on null HTTPRequest object

This commit is contained in:
Kunal Hari 2021-04-13 14:06:21 +12:00
parent 77c85daf56
commit 31c5ab2069

View File

@ -938,12 +938,13 @@ class Director implements TemplateGlobalProvider
public static function absoluteBaseURLWithAuth(HTTPRequest $request = null) public static function absoluteBaseURLWithAuth(HTTPRequest $request = null)
{ {
// Detect basic auth // Detect basic auth
$user = $request->getHeader('PHP_AUTH_USER'); $login = '';
if ($user) { if ($request) {
$password = $request->getHeader('PHP_AUTH_PW'); $user = $request->getHeader('PHP_AUTH_USER');
$login = sprintf("%s:%s@", $user, $password) ; if ($user) {
} else { $password = $request->getHeader('PHP_AUTH_PW');
$login = ''; $login = sprintf("%s:%s@", $user, $password);
}
} }
return Director::protocol($request) . $login . static::host($request) . Director::baseURL(); return Director::protocol($request) . $login . static::host($request) . Director::baseURL();