From d7e381979a2921437d5fd3a52b1093aac7a4102c Mon Sep 17 00:00:00 2001 From: Sebastian Michaelsen Date: Tue, 10 Mar 2026 11:56:24 +0100 Subject: [PATCH] fix: handle valueless Cache-Control directives --- Classes/Service/ResponseCachingService.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Classes/Service/ResponseCachingService.php b/Classes/Service/ResponseCachingService.php index e430e6f..db032c6 100644 --- a/Classes/Service/ResponseCachingService.php +++ b/Classes/Service/ResponseCachingService.php @@ -65,15 +65,24 @@ public function storeCacheEntry(ServerRequestInterface $request, ResponseInterfa foreach ($cacheControlHeaders as $cacheControlHeader) { $valueParts = GeneralUtility::trimExplode(',', $cacheControlHeader); foreach ($valueParts as $valuePart) { + $valuePart = trim($valuePart); if ($valuePart === 'no-cache' || $valuePart === 'no-store') { if (!empty($GLOBALS['TYPO3_CONF_VARS']['FE']['debug'])) { $response = $response->withAddedHeader('X-APP-ROUTES-UNCACHED', 'caching prohibited by Cache-Control header'); } return $response; } - [$key, $value] = GeneralUtility::trimExplode('=', $valuePart); + + if (!str_contains($valuePart, '=')) { + continue; + } + + [$key, $value] = array_map('trim', explode('=', $valuePart, 2)); if ($key === 'max-age') { - $lifetime = $value; + $value = trim($value, '"'); + if (ctype_digit($value)) { + $lifetime = (int)$value; + } } } }