[BUGFIX] Prevent duplicate '/' in filepath when uploading file 04/37204/2
authorSascha Egerer <sascha.egerer@dkd.de>
Mon, 23 Feb 2015 11:02:46 +0000 (12:02 +0100)
committerAlexander Opitz <opitz.alexander@googlemail.com>
Wed, 25 Feb 2015 13:48:24 +0000 (14:48 +0100)
To prevent a duplicate '/' in a filepath the function
LocalDriver::getAbsolutePath should be used instead of
concatenating strings by hand.
This fixes also an issue that file uploads are not
possible on windows machines due to a incorrect filepath.

Resolves: #65230
Releases: master, 6.2
Change-Id: Ibe6ff9c8c1d6579c8da24f14cfd6e528f57a8e4f
Reviewed-on: http://review.typo3.org/37204
Reviewed-by: Sascha Egerer <sascha@sascha-egerer.de>
Tested-by: Sascha Egerer <sascha@sascha-egerer.de>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php

index 89270db..2603aff 100644 (file)
@@ -653,7 +653,7 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver {
                }
                $newFileName = $this->sanitizeFileName($newFileName !== '' ? $newFileName : PathUtility::basename($localFilePath));
                $newFileIdentifier = $this->canonicalizeAndCheckFolderIdentifier($targetFolderIdentifier) . $newFileName;
-               $targetPath = $this->absoluteBasePath . $newFileIdentifier;
+               $targetPath = $this->getAbsolutePath($newFileIdentifier);
 
                if ($removeOriginal) {
                        if (is_uploaded_file($localFilePath)) {
@@ -768,8 +768,9 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver {
                $newIdentifier = $targetFolderIdentifier . '/' . $fileName;
                $newIdentifier = $this->canonicalizeAndCheckFileIdentifier($newIdentifier);
 
-               copy($sourcePath, $this->absoluteBasePath . $newIdentifier);
-               GeneralUtility::fixPermissions($this->absoluteBasePath . $newIdentifier);
+               $absoluteFilePath = $this->getAbsolutePath($newIdentifier);
+               copy($sourcePath, $absoluteFilePath);
+               GeneralUtility::fixPermissions($absoluteFilePath);
                return $newIdentifier;
        }