From 74d35a0c0276192dc2a19fbfc2f82d19a8bf82c3 Mon Sep 17 00:00:00 2001 From: Simon Schaufelberger Date: Fri, 22 Jul 2022 22:37:40 +0200 Subject: [PATCH] [BUGFIX] Use sanitized filename as source identifier when replacing an image Since the persisted file is stored with a sanitized filename, it must be replaced with a sanitized file name as well, otherwise an error occurs that the source with the un-sanitized file name could not be found. Resolves: #98005 Releases: main, 11.5, 10.4 Change-Id: I9b38316f7a25a281521bff787956dcd6373249d0 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75355 Tested-by: core-ci Tested-by: Christian Kuhn Reviewed-by: Christian Kuhn --- typo3/sysext/core/Classes/Resource/ResourceStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typo3/sysext/core/Classes/Resource/ResourceStorage.php b/typo3/sysext/core/Classes/Resource/ResourceStorage.php index a0af7e171573..c04fc87b4c39 100644 --- a/typo3/sysext/core/Classes/Resource/ResourceStorage.php +++ b/typo3/sysext/core/Classes/Resource/ResourceStorage.php @@ -2088,7 +2088,7 @@ public function renameFile($file, $targetFileName, $conflictMode = DuplicationBe } elseif ($conflictMode->equals(DuplicationBehavior::CANCEL)) { throw $exception; } elseif ($conflictMode->equals(DuplicationBehavior::REPLACE)) { - $sourceFileIdentifier = substr($file->getCombinedIdentifier(), 0, (int)strrpos($file->getCombinedIdentifier(), '/') + 1) . $targetFileName; + $sourceFileIdentifier = substr($file->getCombinedIdentifier(), 0, (int)strrpos($file->getCombinedIdentifier(), '/') + 1) . $sanitizedTargetFileName; $sourceFile = $this->getResourceFactoryInstance()->getFileObjectFromCombinedIdentifier($sourceFileIdentifier); $file = $this->replaceFile($sourceFile, Environment::getPublicPath() . '/' . $file->getPublicUrl()); }