Skip to content

Commit

Permalink
[BUGFIX] Prevent call getHeader() on null HTTPRequest object
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunal Hari committed Apr 13, 2021
1 parent 77c85da commit 31c5ab2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Control/Director.php
Original file line number Diff line number Diff line change
Expand Up @@ -938,12 +938,13 @@ public static function absoluteBaseURL()
public static function absoluteBaseURLWithAuth(HTTPRequest $request = null)
{
// Detect basic auth
$user = $request->getHeader('PHP_AUTH_USER');
if ($user) {
$password = $request->getHeader('PHP_AUTH_PW');
$login = sprintf("%s:%s@", $user, $password) ;
} else {
$login = '';
$login = '';
if ($request) {
$user = $request->getHeader('PHP_AUTH_USER');
if ($user) {
$password = $request->getHeader('PHP_AUTH_PW');
$login = sprintf("%s:%s@", $user, $password);
}
}

return Director::protocol($request) . $login . static::host($request) . Director::baseURL();
Expand Down

0 comments on commit 31c5ab2

Please sign in to comment.