[BUGFIX] Handling of uploaded files not within open_basedir 88/42888/6
authorBernhard Kraft <kraft@webconsulting.at>
Thu, 27 Aug 2015 12:12:16 +0000 (14:12 +0200)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 13 Nov 2015 19:51:01 +0000 (20:51 +0100)
When the "upload_tmp_dir" folder is not within the "open_basedir"
an Exception will get thrown when uploading files in the fileadmin.
This patch silences open_basedir() warnings occuring in the file_exists()
check and adds detection of uploaded files as the handling of these with
move_uploaded_file() is not influenced by the open_basedir setting.

Resolves: #69356
Releases: master, 6.2
Change-Id: I2e6b14f207cfd88de04e522e8bcc1bfce72cb0e1
Reviewed-on: https://review.typo3.org/42888
Reviewed-by: Frank N├Ągler <frank.naegler@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Sommer <markussom@posteo.de>
Tested-by: Markus Sommer <markussom@posteo.de>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/core/Classes/Resource/ResourceStorage.php

index 724c0e0..8f9f0eb 100644 (file)
@@ -1152,7 +1152,8 @@ class ResourceStorage implements ResourceStorageInterface
     public function addFile($localFilePath, Folder $targetFolder, $targetFileName = '', $conflictMode = DuplicationBehavior::RENAME)
     {
         $localFilePath = PathUtility::getCanonicalPath($localFilePath);
-        if (!file_exists($localFilePath)) {
+        // File is not available locally NOR is it an uploaded file
+        if (!is_uploaded_file($localFilePath) && !file_exists($localFilePath)) {
             throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1319552745);
         }
         $conflictMode = DuplicationBehavior::cast($conflictMode);