Unverified Commit c7bfe49a authored by alexpott's avatar alexpott
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
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment