[BUGFIX] Canonicalize path before checking existence 32/30532/3
authorNils Blattner <nb@cabag.ch>
Tue, 3 Jun 2014 11:14:57 +0000 (13:14 +0200)
committerMarkus Klein <klein.t3@mfc-linz.at>
Tue, 3 Jun 2014 14:45:41 +0000 (16:45 +0200)
ResourceFactory fails to detect files in symlinked
scenarios, because the path is not canonicalized before
file existence is checked.

Solution is to canonicalize it and check then.

Resolves: #59303
Releases: 6.2
Change-Id: I4fd763f7076e909f2163af79ed2b7f8642da8ed7
Reviewed-on: https://review.typo3.org/30532
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/core/Classes/Resource/ResourceFactory.php

index d34646c..433f780 100644 (file)
@@ -458,13 +458,17 @@ class ResourceFactory implements ResourceFactoryInterface, \TYPO3\CMS\Core\Singl
                        } else {
                                return NULL;
                        }
-               // this is a backwards-compatible way to access "0-storage" files or folders
-               } elseif (@is_file(PATH_site . $input)) {
-                       // only the local file
-                       return $this->getFileObjectFromCombinedIdentifier($input);
                } else {
-                       // only the local path
-                       return $this->getFolderObjectFromCombinedIdentifier($input);
+                       // this is a backwards-compatible way to access "0-storage" files or folders
+                       // eliminate double slashes, /./ and /../
+                       $input = \TYPO3\CMS\Core\Utility\PathUtility::getCanonicalPath(ltrim($input, '/'));
+                       if (@is_file(PATH_site . $input)) {
+                               // only the local file
+                               return $this->getFileObjectFromCombinedIdentifier($input);
+                       } else {
+                               // only the local path
+                               return $this->getFolderObjectFromCombinedIdentifier($input);
+                       }
                }
        }