add fallback to system-hostname for faulty http-clients not setting 'Host' in the request

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2023-02-03 13:59:12 +01:00
parent 0a51d97684
commit ee8385467b

View File

@@ -92,6 +92,17 @@ class UI
*/
public static function sendHeaders()
{
if (empty($_SERVER['HTTP_HOST'])) {
if (!self::$install_mode) {
// fallback to set hostname in settings
$_SERVER['HTTP_HOST'] = Settings::Get('system.hostname');
} else {
// bad request
http_response_code(400);
exit();
}
}
session_set_cookie_params([
'lifetime' => self::$install_mode ? 7200 : 600, // will be renewed based on settings in lib/init.php
'path' => '/',