From 8abf1ac6cea0ea07e9bd8ff4aaf9be48c6a20d90 Mon Sep 17 00:00:00 2001
From: Susanne Moog <look@susi.dev>
Date: Wed, 25 Mar 2020 18:27:24 +0100
Subject: [PATCH] [BUGFIX] Fix target path handling of UploadedFile
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The PSR-7 interface states that moveTo shall use `$target` as full
`$target` path (including the file name) for uploaded files. In addition,
the current implementation was inconsistent when handling streams vs.
files. The implementation has been adjusted according to the standard.

Resolves: #77870
Releases: master
Change-Id: I2f3a43b4640a77955b25a11b5398c82e78da6af4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63920
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
---
 typo3/sysext/core/Classes/Http/UploadedFile.php | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/typo3/sysext/core/Classes/Http/UploadedFile.php b/typo3/sysext/core/Classes/Http/UploadedFile.php
index 2e666a2a7f44..a125bbdb29d4 100644
--- a/typo3/sysext/core/Classes/Http/UploadedFile.php
+++ b/typo3/sysext/core/Classes/Http/UploadedFile.php
@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Core\Http;
 use Psr\Http\Message\StreamInterface;
 use Psr\Http\Message\UploadedFileInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\PathUtility;
 
 /**
  * Class UploadedFile which represents one uploaded file, usually coming
@@ -186,7 +185,7 @@ class UploadedFile implements UploadedFileInterface
         }
 
         if (!empty($this->file) && is_uploaded_file($this->file)) {
-            if (GeneralUtility::upload_copy_move($this->file, $targetPath . PathUtility::basename($this->file)) === false) {
+            if (GeneralUtility::upload_copy_move($this->file, $targetPath) === false) {
                 throw new \RuntimeException('An error occurred while moving uploaded file', 1436717310);
             }
         } elseif ($this->stream) {
-- 
GitLab