Skip to content

Commit

Permalink
[BUGFIX] Use sanitized filename as source identifier when replacing a…
Browse files Browse the repository at this point in the history
…n 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/+/75356
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
simonschaufi authored and lolli42 committed Aug 5, 2022
1 parent 4408fa2 commit 6739feb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion typo3/sysext/core/Classes/Resource/ResourceStorage.php
Expand Up @@ -2077,7 +2077,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());
}
Expand Down

0 comments on commit 6739feb

Please sign in to comment.