Skip to content

Commit

Permalink
Prepare CSP infos
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Nov 2, 2024
1 parent 181d978 commit 11beb72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Classes/Cache/Listener/NoIntScriptsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SFC\Staticfilecache\Cache\Listener;

use SFC\Staticfilecache\Event\CacheRuleEvent;
use TYPO3\CMS\Frontend\Cache\NonceValueSubstitution;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

class NoIntScriptsListener
Expand All @@ -14,6 +15,12 @@ public function __invoke(CacheRuleEvent $event): void
$tsfe = $GLOBALS['TSFE'] ?? null;
if ($tsfe instanceof TypoScriptFrontendController && $tsfe->isINTincScript()) {
foreach ((array) $tsfe->config['INTincScript'] as $key => $configuration) {

// Check CSP Handling
// if (isset($configuration['target']) && $configuration['target'] === NonceValueSubstitution::class . '->substituteNonce') {
// continue;
// }

$event->addExplanation(__CLASS__ . ':' . $key, 'The page has a INTincScript: ' . implode(', ', $this->getInformation($configuration)));
}
}
Expand Down
2 changes: 2 additions & 0 deletions Classes/Cache/Listener/StaticCacheableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public function __construct(private readonly Typo3Version $typo3Version) {}
*/
public function __invoke(CacheRuleEvent $event): void
{
// @todo migrate this event to check
// $request->getAttribute('frontend.cache.instruction')->isCachingAllowed()
if (($GLOBALS['TSFE'] ?? null) instanceof TypoScriptFrontendController) {
if ($this->typo3Version->getMajorVersion() >= 13) {
/* @phpstan-ignore-next-line */
Expand Down

0 comments on commit 11beb72

Please sign in to comment.