Skip to content

Commit

Permalink
[BUGFIX] Properly check (real)paths in LocalCropScaleMaskHelper
Browse files Browse the repository at this point in the history
With patches #102679 and arguably #103351, the image processing got
refactored at multiple locations with good intentions. However, this
triggers a bug in case `fileadmin/` is symlinked as it removes original
files from `fileadmin/` due to incomplete checks.

The class `LocalCropScaleMaskHelper` compares two paths to check whether
further processing needs to be done. One part of the condition is the
path "as-is", the other one is the real path with symlinks being
resolved, leading to a negative result albeit both paths point to the
exact same file.

Another condition to trigger this bug is to render images in the
frontend that don't need processing at all, e.g. because their
dimensions are small enough.

This patch converts the original file name in `LocalCropScaleMaskHelper`
to a real path as well to have a successful comparison in symlink
scenarios.

Resolves: #103648
Releases: main
Change-Id: I81e7f9d3e8951a0a0f18fe2838925f272659028e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83846
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: Benni Mack <benni@typo3.org>
  • Loading branch information
andreaskienast authored and bnf committed Apr 22, 2024
1 parent 8dc13c1 commit c7b47d6
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -121,7 +121,9 @@ public function processWithLocalFile(TaskInterface $task, string $originalFileNa

// check if the processing really generated a new file (scaled and/or cropped)
if ($result !== null) {
if ($result->getRealPath() !== $originalFileName) {
// @todo: realpath handling should be revisited, they may produce issues
// with open_basedir restrictions and/or lockRootPath.
if ($result->getRealPath() !== realpath($originalFileName)) {
$result = [
'width' => $result->getWidth(),
'height' => $result->getHeight(),
Expand Down

0 comments on commit c7b47d6

Please sign in to comment.