diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index 83e7b782889107573b99d722c8120b95096f9f53..3b1264f1dcf5c68c087d0c7e8adadbdd95eab569 100644 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -2437,7 +2437,10 @@ class GeneralUtility public static function createVersionNumberedFilename($file) { $lookupFile = explode('?', $file); - $path = self::resolveBackPath(self::dirname(Environment::getCurrentScript()) . '/' . $lookupFile[0]); + $path = $lookupFile[0]; + if (!PathUtility::isAbsolutePath($path)) { + $path = self::resolveBackPath(self::dirname(Environment::getCurrentScript()) . '/' . $path); + } $doNothing = false; if (TYPO3_MODE === 'FE') { @@ -2474,7 +2477,7 @@ class GeneralUtility array_push($name, filemtime($path), $extension); $fullName = implode('.', $name); // Append potential query string - $fullName .= $lookupFile[1] ? '?' . $lookupFile[1] : ''; + $fullName .= !empty($lookupFile[1]) ? '?' . $lookupFile[1] : ''; } } return $fullName; diff --git a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php index 8e6da0dbaf9021c128a992b4f00696010d49281f..67f7a5d24f530a7c1404c93030ee53b75b3495d8 100644 --- a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php +++ b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php @@ -4606,4 +4606,23 @@ class GeneralUtilityTest extends UnitTestCase $result = GeneralUtility::locationHeaderUrl($path); self::assertSame($expected, $result); } + + /** + * @test + */ + public function createVersionNumberedFilenameDoesNotResolveBackpathForAbsolutePath(): void + { + $GLOBALS['TYPO3_CONF_VARS']['BE']['versionNumberInFilename'] = true; + + $uniqueFilename = StringUtility::getUniqueId() . 'backend'; + $testFileDirectory = Environment::getVarPath() . '/tests/'; + $testFilepath = $testFileDirectory . $uniqueFilename . '.css'; + $this->testFilesToDelete[] = $testFilepath; + GeneralUtility::mkdir_deep($testFileDirectory); + touch($testFilepath); + + $versionedFilename = GeneralUtility::createVersionNumberedFilename($testFilepath); + + self::assertRegExp('/^.*\/tests\/' . $uniqueFilename . '\.[0-9]+\.css/', $versionedFilename); + } }