Skip to content
Snippets Groups Projects
Unverified Commit c7bfe49a authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2924860 by Kng, AdamPS: “Uncaught exception” page contains HTML but has...

Issue #2924860 by Kng, AdamPS: “Uncaught exception” page contains HTML but has content-type text/plain
parent aea4a9b5
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -123,9 +123,10 @@ public function onException(GetResponseForExceptionEvent $event) {
}
}
$content_type = $event->getRequest()->getRequestFormat() == 'html' ? 'text/html' : 'text/plain';
$content = $this->t('The website encountered an unexpected error. Please try again later.');
$content .= $message ? '</br></br>' . $message : '';
$response = new Response($content, 500, ['Content-Type' => 'text/plain']);
$response = new Response($content, 500, ['Content-Type' => $content_type]);
if ($exception instanceof HttpExceptionInterface) {
$response->setStatusCode($exception->getStatusCode());
......
......@@ -157,7 +157,7 @@ public function testBacktraceEscaping() {
$kernel = \Drupal::getContainer()->get('http_kernel');
$response = $kernel->handle($request)->prepare($request);
$this->assertEqual($response->getStatusCode(), Response::HTTP_INTERNAL_SERVER_ERROR);
$this->assertEqual($response->headers->get('Content-type'), 'text/plain; charset=UTF-8');
$this->assertEqual($response->headers->get('Content-type'), 'text/html; charset=UTF-8');
// Test both that the backtrace is properly escaped, and that the unescaped
// string is not output at all.
......@@ -180,7 +180,7 @@ public function testExceptionEscaping() {
$kernel = \Drupal::getContainer()->get('http_kernel');
$response = $kernel->handle($request)->prepare($request);
$this->assertEqual($response->getStatusCode(), Response::HTTP_INTERNAL_SERVER_ERROR);
$this->assertEqual($response->headers->get('Content-type'), 'text/plain; charset=UTF-8');
$this->assertEqual($response->headers->get('Content-type'), 'text/html; charset=UTF-8');
// Test message is properly escaped, and that the unescaped string is not
// output at all.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment