Project

General

Profile

Actions

Bug #93716

closed

Problems with UTF-8 filenames, in cImage the imageLinkWrap gets the public path as identifier

Added by Stefan Berger over 3 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2021-03-12
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Hi,

we have noticed that there is a problem with uft8 filenames of images when they are processed using imageLinkWrap.

The problem starts in the method TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getImgResource:

    public function getImgResource($file, $fileArray)
    {
...
                            'origFile' => $fileObject->getPublicUrl(),                   // <<<<------
                            'origFile_mtime' => $fileObject->getModificationTime(),
                            // This is needed by \TYPO3\CMS\Frontend\Imaging\GifBuilder,
                            // in order for the setup-array to create a unique filename hash.
                            'originalFile' => $fileObject,
                            'processedFile' => $processedFileObject
...

The value $info['originalFile'] will be removed later in the method TYPO3\CMS\Frontend\ContentObject\ImageContentObject::cImage:

...
        // Remove file objects for AssetCollector, as it only allows to store scalar values
        unset($info['originalFile'], $info['processedFile']);
        GeneralUtility::makeInstance(AssetCollector::class)->addMedia(
            $source,
            $info
        );
...

This means that the public path is used to call the imageLinkWrap function in the method TYPO3\CMS\Frontend\ContentObject\ImageContentObject::cImage:

...
        } elseif ($conf['imageLinkWrap']) {
            $originalFile = !empty($info['originalFile']) ? $info['originalFile'] : $info['origFile'];
            $theValue = $this->cObj->imageLinkWrap($theValue, $originalFile, $conf['imageLinkWrap.']);
        }
...

Which ultimately leads to a fatal result when determining the file object later in the method TYPO3\CMS\Core\Resource\Driver\LocalDriver::getFileInfoByIdentifier:

...
        $absoluteFilePath = $this->getAbsolutePath($fileIdentifier);
        // don't use $this->fileExists() because we need the absolute path to the file anyways, so we can directly
        // use PHP's filesystem method.
        if (!file_exists($absoluteFilePath) || !is_file($absoluteFilePath)) {
            throw new \InvalidArgumentException('File ' . $fileIdentifier . ' does not exist.', 1314516809);
        }
...

A workaround could be that the identifier is urldecoded after it has been entered in the ResourceFactory or that the public path for the array index 'origFile' is not used at all but the real path is used.

Thanks for fixing.


Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #90757: ContentObjectRenderer is not able to handle files with UmlautsClosed2020-03-13

Actions
Related to TYPO3 Core - Bug #90565: PageRenderer, Assetcollector - Serialization of Closure is not allowedClosed2020-02-28

Actions
Related to TYPO3 Core - Bug #97430: Undefined array key "originalFile" in ImageContentObjectClosed2022-04-19

Actions
Actions

Also available in: Atom PDF