mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2026-11-20 23:43:26 +03:00
Send the 419 status with a reason phrase so Apache does not answer 500 (#1209)
Fixes #1208 - add reason phrase with http 419 response (used with invalid or missing CSRF token is answered with the "Session expired"), otherwise Apache returns a http 500 response instead. thanks @vibpe
This commit is contained in:
1 parent
5cc297210b
commit
7a1eb67db2
1 file changed
+4
-1
+4
-1
@@ -6,7 +6,10 @@ set_exception_handler(function ($exception) {
|
||||
|
||||
// we could do something much better here - e.g. if the user is logged in, and an admin, show a full stack trace etc.
|
||||
if ($exception instanceof CsrfInvalidException) {
|
||||
http_response_code(419); // HTTP 419 Page Expired.
|
||||
// 419 is not a registered status code: without an explicit reason phrase
|
||||
// Apache replaces the status line with "500 Internal Server Error".
|
||||
// Always HTTP/1.1: mod_php only applies a status line starting with "HTTP/1.".
|
||||
header('HTTP/1.1 419 Page Expired', true, 419);
|
||||
$title = Config::lang('session_expired_title') ?: 'Session expired';
|
||||
$message = Config::lang('session_expired_message') ?: 'The page token is no longer valid. Please return and try again.';
|
||||
$button = Config::lang('session_expired_button') ?: 'Continue';
|
||||
|
||||
Reference in new issue
Block a user