Skip to content
Snippets Groups Projects
Commit 1d65ffe0 authored by Markus Klein's avatar Markus Klein Committed by Wouter Wolters
Browse files

[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: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: default avatarJoerg Boesche <typo3@joergboesche.de>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
parent 553681a2
Branches
Tags
No related merge requests found
...@@ -419,9 +419,16 @@ class ResourceCompressor ...@@ -419,9 +419,16 @@ class ResourceCompressor
*/ */
protected function getFilenameFromMainDir($filename) 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 the file exists in the root path, just return the $filename
if (is_file($this->rootPath . ltrim($filename, '/'))) { if (is_file($this->rootPath . $fileNameWithoutSlash)) {
return ltrim($filename, '/'); return $fileNameWithoutSlash;
} }
// if the file is from a special TYPO3 internal directory, add the missing typo3/ prefix // if the file is from a special TYPO3 internal directory, add the missing typo3/ prefix
if (is_file(realpath(PATH_site . TYPO3_mainDir . $filename))) { if (is_file(realpath(PATH_site . TYPO3_mainDir . $filename))) {
...@@ -433,7 +440,7 @@ class ResourceCompressor ...@@ -433,7 +440,7 @@ class ResourceCompressor
} elseif (strpos($filename, '../') === 0) { } elseif (strpos($filename, '../') === 0) {
$file = GeneralUtility::resolveBackPath(PATH_typo3 . $filename); $file = GeneralUtility::resolveBackPath(PATH_typo3 . $filename);
} else { } 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 // check if the file exists, and if so, return the path relative to TYPO3_mainDir
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment