[BUGFIX] Prevent duplicate '/' in filepath when uploading file 04/37104/3
authorSascha Egerer <sascha.egerer@dkd.de>
Mon, 23 Feb 2015 11:02:46 +0000 (12:02 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Wed, 25 Feb 2015 11:36:34 +0000 (12:36 +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/37104
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php

index 330c078..b543c22 100644 (file)
@@ -640,7 +640,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)) {
@@ -755,8 +755,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;
        }