From 1d65ffe0f772e56dc0e19b8ffc84bf1a498cbbfd Mon Sep 17 00:00:00 2001 From: Markus Klein <markus.klein@typo3.org> Date: Fri, 25 Nov 2016 20:29:55 +0100 Subject: [PATCH] [BUGFIX] ResourceCompressor must deal with absolute web paths ResourceCompressor lacks the ability to compress files which are registered with their absolute web path (as FormEngine does). Add a check to resolve such paths correctly. Resolves: #78803 Releases: master Change-Id: Id42b0889243e898dfb01a018974e5db51675a15b Reviewed-on: https://review.typo3.org/50782 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Georg Ringer <georg.ringer@gmail.com> Tested-by: Georg Ringer <georg.ringer@gmail.com> Reviewed-by: Joerg Boesche <typo3@joergboesche.de> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Tested-by: Wouter Wolters <typo3@wouterwolters.nl> --- .../core/Classes/Resource/ResourceCompressor.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/typo3/sysext/core/Classes/Resource/ResourceCompressor.php b/typo3/sysext/core/Classes/Resource/ResourceCompressor.php index 91359ef0c14e..a8fbffbdd3eb 100644 --- a/typo3/sysext/core/Classes/Resource/ResourceCompressor.php +++ b/typo3/sysext/core/Classes/Resource/ResourceCompressor.php @@ -419,9 +419,16 @@ class ResourceCompressor */ protected function getFilenameFromMainDir($filename) { + $docRoot = GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT'); + $fileNameWithoutSlash = ltrim($filename, '/'); + + // if the file exists in the document root + if (is_file($docRoot . '/' . $fileNameWithoutSlash)) { + return substr($docRoot . '/' . $fileNameWithoutSlash, strlen($this->rootPath)); + } // if the file exists in the root path, just return the $filename - if (is_file($this->rootPath . ltrim($filename, '/'))) { - return ltrim($filename, '/'); + if (is_file($this->rootPath . $fileNameWithoutSlash)) { + return $fileNameWithoutSlash; } // if the file is from a special TYPO3 internal directory, add the missing typo3/ prefix if (is_file(realpath(PATH_site . TYPO3_mainDir . $filename))) { @@ -433,7 +440,7 @@ class ResourceCompressor } elseif (strpos($filename, '../') === 0) { $file = GeneralUtility::resolveBackPath(PATH_typo3 . $filename); } else { - $file = PATH_site . ltrim($filename, '/'); + $file = PATH_site . $fileNameWithoutSlash; } // check if the file exists, and if so, return the path relative to TYPO3_mainDir -- GitLab