[BUGFIX] Handling of uploaded files not within open_basedir 10/44710/2
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 13 Nov 2015 19:55:54 +0000 (20:55 +0100)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 13 Nov 2015 19:58:53 +0000 (20:58 +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: I649373e8910c2d30f73cbb0e3b56476196c151fd
Reviewed-on: https://review.typo3.org/44710
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/core/Classes/Resource/ResourceStorage.php

index e0bb887..a270472 100644 (file)
@@ -1082,7 +1082,8 @@ class ResourceStorage implements ResourceStorageInterface {
         */
        public function addFile($localFilePath, Folder $targetFolder, $targetFileName = '', $conflictMode = 'changeName') {
                $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);
                }
                $targetFolder = $targetFolder ?: $this->getDefaultFolder();