Commit 6739febe authored by Simon Schaufelberger's avatar Simon Schaufelberger Committed by Christian Kuhn
Browse files

[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/+/75356

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 4408fa2f
......@@ -2077,7 +2077,7 @@ class ResourceStorage implements ResourceStorageInterface
} 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());
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment