From 4bf87fc69207383eccd41497d4f0db4b99556bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Lochm=C3=BCller?= Date: Sun, 27 Oct 2024 21:31:12 +0100 Subject: [PATCH] Fix #416 - Only add Link path if the path is ASCII compatible --- Classes/Middleware/PrepareMiddleware.php | 4 +++- Classes/Service/HttpPush/AbstractHttpPush.php | 1 - Configuration/Services.yaml | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Classes/Middleware/PrepareMiddleware.php b/Classes/Middleware/PrepareMiddleware.php index 89599c9f34a..f099d0143db 100644 --- a/Classes/Middleware/PrepareMiddleware.php +++ b/Classes/Middleware/PrepareMiddleware.php @@ -70,7 +70,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface $pushHeaders = (array) $this->httpPushService->getHttpPushHeaders((string) $response->getBody()); foreach ($pushHeaders as $pushHeader) { - $response = $response->withAddedHeader('Link', '<' . $pushHeader['path'] . '>; rel=preload; as=' . $pushHeader['type']); + if (mb_detect_encoding($pushHeader['path'], 'ASCII', true)) { + $response = $response->withAddedHeader('Link', '<' . $pushHeader['path'] . '>; rel=preload; as=' . $pushHeader['type']); + } } return $response; diff --git a/Classes/Service/HttpPush/AbstractHttpPush.php b/Classes/Service/HttpPush/AbstractHttpPush.php index 9ec217c4846..2f2172f737b 100644 --- a/Classes/Service/HttpPush/AbstractHttpPush.php +++ b/Classes/Service/HttpPush/AbstractHttpPush.php @@ -14,7 +14,6 @@ public function __invoke(HttpPushHeaderEvent $event): void foreach ($event->getExtensions() as $extension) { if ($this->canHandleExtension($extension)) { $event->setHeaders(array_merge($event->getHeaders(), $this->getHeaders($event->getContent()))); - ; } } } diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index adc96be9aae..5cb4ec5d7d6 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -165,25 +165,25 @@ services: SFC\Staticfilecache\Service\HttpPush\ScriptHttpPush: tags: - name: event.listener - identifier: 'StyleHttpPush' + identifier: 'ScriptHttpPush' event: SFC\Staticfilecache\Event\HttpPushHeaderEvent SFC\Staticfilecache\Service\HttpPush\ImageHttpPush: tags: - name: event.listener - identifier: 'StyleHttpPush' + identifier: 'ImageHttpPush' event: SFC\Staticfilecache\Event\HttpPushHeaderEvent SFC\Staticfilecache\Service\HttpPush\FontHttpPush: tags: - name: event.listener - identifier: 'StyleHttpPush' + identifier: 'FontHttpPush' event: SFC\Staticfilecache\Event\HttpPushHeaderEvent SFC\Staticfilecache\Service\HttpPush\SvgHttpPush: tags: - name: event.listener - identifier: 'StyleHttpPush' + identifier: 'SvgHttpPush' event: SFC\Staticfilecache\Event\HttpPushHeaderEvent SFC\Staticfilecache\Generator\ConfigGenerator: