From 90a22e0e1b16151f26861ab1f324d91ad31dc6c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Mon, 7 Mar 2022 16:31:18 +0100 Subject: [PATCH] Remove html compression middleware --- .../Classes/Middleware/HtmlCompress.php | 54 ------------------- .../Configuration/RequestMiddlewares.php | 9 ---- 2 files changed, 63 deletions(-) delete mode 100644 public/typo3conf/ext/ep_theme/Classes/Middleware/HtmlCompress.php diff --git a/public/typo3conf/ext/ep_theme/Classes/Middleware/HtmlCompress.php b/public/typo3conf/ext/ep_theme/Classes/Middleware/HtmlCompress.php deleted file mode 100644 index 80ea0b71..00000000 --- a/public/typo3conf/ext/ep_theme/Classes/Middleware/HtmlCompress.php +++ /dev/null @@ -1,54 +0,0 @@ -handle($request); - - $compressionEnabled = GeneralUtility::makeInstance(ExtensionConfiguration::class) - ->get('ep_theme', 'compressHtml'); - - if (false === (bool)$compressionEnabled || $this->isTypeNumSet($request)) { - return $response; - } - - $stream = $response->getBody(); - $stream->rewind(); - $content = $stream->getContents(); - $newBody = (new StreamFactory())->createStream($this->compressHtml($content)); - $response = $response->withBody($newBody); - - return $response; - } - - protected function compressHtml(string $html): string - { - $parser = Factory::construct(); - $html = $parser->compress($html); - $html = $this->removeComments($html); - - return $html; - } - - protected function removeComments(string $html): string - { - return preg_replace('//', '', $html); - } - - protected function isTypeNumSet(ServerRequestInterface $request): bool - { - return $request->getAttribute('routing')->getPageType() > 0; - } -} diff --git a/public/typo3conf/ext/ep_theme/Configuration/RequestMiddlewares.php b/public/typo3conf/ext/ep_theme/Configuration/RequestMiddlewares.php index 42336d11..ec4ed8b7 100644 --- a/public/typo3conf/ext/ep_theme/Configuration/RequestMiddlewares.php +++ b/public/typo3conf/ext/ep_theme/Configuration/RequestMiddlewares.php @@ -8,14 +8,5 @@ return [ 'typo3/cms-frontend/site', ], ], - 'ep/html-compress' => [ - 'target' => \EP\EpTheme\Middleware\HtmlCompress::class, - 'before' => [ - 'typo3/cms-frontend/output-compression' - ], - 'after' => [ - 'typo3/cms-adminpanel/renderer' - ], - ], ], ];