Skip to content

Commit

Permalink
Fix #416 - Only add Link path if the path is ASCII compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Oct 27, 2024
1 parent 3933d9b commit 4bf87fc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Classes/Middleware/PrepareMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion Classes/Service/HttpPush/AbstractHttpPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())));
;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4bf87fc

Please sign in to comment.