1919use Psr \Http \Message \ServerRequestInterface ;
2020use Psr \Http \Server \MiddlewareInterface ;
2121use Psr \Http \Server \RequestHandlerInterface ;
22+ use TYPO3 \CMS \Core \Cache \CacheManager ;
2223use TYPO3 \CMS \Core \Core \Environment ;
2324use TYPO3 \CMS \Core \Http \RedirectResponse ;
2425use TYPO3 \CMS \Core \Information \Typo3Version ;
2526use TYPO3 \CMS \Core \Resource \ResourceFactory ;
2627use TYPO3 \CMS \Core \Resource \Security \FileNameValidator ;
28+ use TYPO3 \CMS \Core \Site \Entity \NullSite ;
2729use TYPO3 \CMS \Core \TimeTracker \TimeTracker ;
30+ use TYPO3 \CMS \Core \TypoScript \PageTsConfig ;
31+ use TYPO3 \CMS \Core \TypoScript \PageTsConfigFactory ;
2832use TYPO3 \CMS \Core \Utility \GeneralUtility ;
2933use TYPO3 \CMS \Frontend \Controller \TypoScriptFrontendController ;
3034
@@ -69,7 +73,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
6973 }
7074 // Regular jump URL
7175 $ this ->validateIfJumpUrlRedirectIsAllowed ($ jumpUrl , $ juHash );
72- return $ this ->redirectToJumpUrl ($ jumpUrl );
76+ return $ this ->redirectToJumpUrl ($ jumpUrl, $ request );
7377 }
7478 return $ handler ->handle ($ request );
7579 }
@@ -81,9 +85,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
8185 * @throws \Exception
8286 * @return ResponseInterface
8387 */
84- protected function redirectToJumpUrl (string $ jumpUrl ): ResponseInterface
88+ protected function redirectToJumpUrl (string $ jumpUrl, ServerRequestInterface $ request ): ResponseInterface
8589 {
86- $ pageTSconfig = $ this ->getTypoScriptFrontendController ()-> getPagesTSconfig ( );
90+ $ pageTSconfig = $ this ->getPageTsConfig ( $ request );
8791 $ pageTSconfig = array_key_exists ('TSFE. ' , $ pageTSconfig ) && is_array ($ pageTSconfig ['TSFE. ' ] ?? false ) ? $ pageTSconfig ['TSFE. ' ] : [];
8892
8993 // Allow sections in links
@@ -94,6 +98,30 @@ protected function redirectToJumpUrl(string $jumpUrl): ResponseInterface
9498 return new RedirectResponse ($ jumpUrl , $ statusCode );
9599 }
96100
101+ /**
102+ * @param ServerRequestInterface $request
103+ * @return array
104+ * @throws \JsonException
105+ * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
106+ */
107+ protected function getPageTsConfig (ServerRequestInterface $ request ): array
108+ {
109+ $ pageInformation = $ request ->getAttribute ('frontend.page.information ' );
110+ $ id = $ pageInformation ->getId ();
111+ $ runtimeCache = GeneralUtility::makeInstance (CacheManager::class)->getCache ('runtime ' );
112+ $ pageTsConfig = $ runtimeCache ->get ('pageTsConfig- ' . $ id );
113+ if ($ pageTsConfig instanceof PageTsConfig) {
114+ return $ pageTsConfig ->getPageTsConfigArray ();
115+ }
116+ $ fullRootLine = $ pageInformation ->getRootLine ();
117+ ksort ($ fullRootLine );
118+ $ site = $ request ->getAttribute ('site ' ) ?? new NullSite ();
119+ $ pageTsConfigFactory = GeneralUtility::makeInstance (PageTsConfigFactory::class);
120+ $ pageTsConfig = $ pageTsConfigFactory ->create ($ fullRootLine , $ site );
121+ $ runtimeCache ->set ('pageTsConfig- ' . $ id , $ pageTsConfig );
122+ return $ pageTsConfig ->getPageTsConfigArray ();
123+ }
124+
97125 /**
98126 * If the submitted hash is correct and the user has access to the
99127 * related content element the contents of the submitted file will
@@ -126,15 +154,9 @@ protected function forwardJumpUrlSecureFileData(string $jumpUrl, string $locatio
126154
127155 // Check if requested file accessable
128156 $ fileAccessAllowed = false ;
129- if ((new Typo3Version ())->getMajorVersion () < 11 ) {
130- $ fileAccessAllowed = GeneralUtility::isAllowedAbsPath ($ absoluteFileName )
131- && GeneralUtility::verifyFilenameAgainstDenyPattern ($ absoluteFileName )
132- && !GeneralUtility::isFirstPartOfStr ($ absoluteFileName , Environment::getLegacyConfigPath ());
133- } else {
134- $ fileAccessAllowed = GeneralUtility::isAllowedAbsPath ($ absoluteFileName )
135- && GeneralUtility::makeInstance (FileNameValidator::class)->isValid ($ absoluteFileName )
136- && !str_starts_with ($ absoluteFileName , Environment::getLegacyConfigPath ());
137- }
157+ $ fileAccessAllowed = GeneralUtility::isAllowedAbsPath ($ absoluteFileName )
158+ && GeneralUtility::makeInstance (FileNameValidator::class)->isValid ($ absoluteFileName )
159+ && !str_starts_with ($ absoluteFileName , Environment::getLegacyConfigPath ());
138160 if (!$ fileAccessAllowed ) {
139161 throw new \Exception ('The requested file was not allowed to be accessed through Jump URL. The path or file is not allowed. ' , 1294585194 );
140162 }
@@ -157,7 +179,7 @@ protected function forwardJumpUrlSecureFileData(string $jumpUrl, string $locatio
157179 protected function isLocationDataValid (string $ locationData ): bool
158180 {
159181 $ isValidLocationData = false ;
160- list ( $ pageUid , $ table , $ recordUid) = explode (': ' , $ locationData );
182+ [ $ pageUid , $ table , $ recordUid] = explode (': ' , $ locationData );
161183 $ pageRepository = $ this ->getTypoScriptFrontendController ()->sys_page ;
162184 if (empty ($ table ) || $ pageRepository ->checkRecord ($ table , $ recordUid , true )) {
163185 // This check means that a record is checked only if the locationData has a value for a
0 commit comments