[BUGFIX] Ensure correct absolute paths for fluid template paths 88/46388/3
authorNicole Cordes <typo3@cordes.co>
Sat, 30 Jan 2016 11:09:29 +0000 (12:09 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Mon, 1 Feb 2016 13:34:10 +0000 (14:34 +0100)
This patch uses TYPO3 internal functions to resolves absolute paths
which can handle absolute Windows paths as well.

Resolves: #73028
Releases: master
Change-Id: Id92af6ff12033904002bbbfd845f465a7a9a1519
Reviewed-on: https://review.typo3.org/46388
Tested-by: Daniel Maier <dani-maier@gmx.de>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Daniel Maier <dani-maier@gmx.de>
Tested-by: Riccardo De Contardi <erredeco@gmail.com>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
typo3/sysext/fluid/Classes/View/TemplatePaths.php

index 647c266..ec7d68d 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Fluid\View;
 
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\PathUtility;
 use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 
@@ -121,9 +122,6 @@ class TemplatePaths extends \TYPO3Fluid\Fluid\View\TemplatePaths
             $paths = array_map(array($this, 'sanitizePath'), $path);
             return array_unique($paths);
         }
-        if (substr($path, 0, 1) !== '/') {
-            $path = GeneralUtility::getFileAbsFileName($path);
-        }
         $path = $this->ensureAbsolutePath($path);
         if (is_dir($path)) {
             $path = $this->ensureSuffixedPath($path);
@@ -132,6 +130,30 @@ class TemplatePaths extends \TYPO3Fluid\Fluid\View\TemplatePaths
     }
 
     /**
+     * Guarantees that $reference is turned into a
+     * correct, absolute path. The input can be a
+     * relative path or a FILE: or EXT: reference
+     * but cannot be a FAL resource identifier.
+     *
+     * @param mixed $reference
+     * @return string
+     */
+    protected function ensureAbsolutePath($reference)
+    {
+        if (false === is_array($reference)) {
+            $filename = PathUtility::isAbsolutePath($reference) ? $reference : GeneralUtility::getFileAbsFileName($reference);
+        } else {
+            foreach ($reference as &$subValue) {
+                $subValue = $this->ensureAbsolutePath($subValue);
+            }
+
+            return $reference;
+        }
+
+        return $filename;
+    }
+
+    /**
      * Fills the path arrays with defaults, by package name.
      * Reads those defaults from TypoScript if possible and
      * if not defined, uses fallback paths by convention.