Make the CSP compatible with debug tools

This commit is contained in:
Pierre Rudloff 2020-10-19 23:43:33 +02:00
parent e2560cd9cb
commit 561b6c8370
6 changed files with 194 additions and 2 deletions

View file

@ -6,6 +6,7 @@
namespace Alltube\Controller;
use Alltube\CspMiddleware;
use Alltube\Library\Exception\PasswordException;
use Alltube\Library\Exception\AlltubeLibraryException;
use Alltube\Library\Exception\WrongPasswordException;
@ -295,6 +296,12 @@ class FrontController extends BaseController
{
$this->logger->error($error);
// We apply the CSP manually because middlewares are not called on error pages.
$cspMiddleware = new CspMiddleware($this->container);
/** @var Response $response */
$response = $cspMiddleware->applyHeader($response);
if ($this->config->debug) {
$renderer = new HtmlErrorRenderer(true);
$exception = $renderer->render($error);