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 about 3 years ago. Updated over 1 year 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 #1

Updated by Lars Michalowski over 2 years ago

Hi,

this bug still exists in the current release 10.4.20. To reproduce this:

1. Activate UTF8 filesystem in install tool by setting [SYS][UTF8filesystem] = true and [SYS][systemLocale] = de_DE.utf-8 (or any other utf8 locale fitting your server configuration).

2. Upload an image file to fileadmin/user_upload/nachhaltig-und-zuverlässig.png

3. Create TS template with:

page = PAGE
page.10 = IMAGE
page.10 {
  imageLinkWrap = 1
  imageLinkWrap.enable = 1
  file = fileadmin/user_upload/nachhaltig-und-zuverlässig.png
}

4. Load frontend. This leads to the following exception:

#1314516809 InvalidArgumentException
File /fileadmin/user_upload/nachhaltig-und-zuverl%C3%A4ssig.png does not exist.

5. Set imageLinkWrap = 0 and reload frontend. Image is rendered as expected.

I think a fix of this bug is quite important since it breaks image rendering in the frontend. We can not upgrade to 10.4 at the moment because of this bug.

Actions #2

Updated by Lars Michalowski over 2 years ago

  • Related to Bug #90757: ContentObjectRenderer is not able to handle files with Umlauts added
Actions #3

Updated by Lars Michalowski over 2 years ago

This patch worked for me:

--- typo3_src-10.4.20/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php        2021-09-07 11:05:57.374679234 +0200
+++ typo3_src-10.4.20-patch/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php        2021-09-07 11:08:23.679865925 +0200
@@ -68,6 +68,7 @@
             $source = $info[3];
         }
         // Remove file objects for AssetCollector, as it only allows to store scalar values
+        $infoOriginalFile = $info['originalFile'];
         unset($info['originalFile'], $info['processedFile']);
         GeneralUtility::makeInstance(AssetCollector::class)->addMedia(
             $source,
@@ -104,7 +105,7 @@
         if ($linkWrap) {
             $theValue = $this->linkWrap($theValue, $linkWrap);
         } elseif ($conf['imageLinkWrap']) {
-            $originalFile = !empty($info['originalFile']) ? $info['originalFile'] : $info['origFile'];
+            $originalFile = !empty($infoOriginalFile) ? $infoOriginalFile : urldecode($info['origFile']);
             $theValue = $this->cObj->imageLinkWrap($theValue, $originalFile, $conf['imageLinkWrap.']);
         }
         $wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];

Actions #4

Updated by Gerrit Code Review about 2 years ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/73983

Actions #5

Updated by Christian Kuhn about 2 years ago

  • Related to Bug #90565: PageRenderer, Assetcollector - Serialization of Closure is not allowed added
Actions #6

Updated by Gerrit Code Review about 2 years ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/73983

Actions #7

Updated by Gerrit Code Review about 2 years ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/73983

Actions #8

Updated by Gerrit Code Review about 2 years ago

Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74116

Actions #9

Updated by Lars Michalowski about 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #10

Updated by Nikita Hovratov about 2 years ago

  • Related to Bug #97430: Undefined array key "originalFile" in ImageContentObject added
Actions #11

Updated by Benni Mack over 1 year ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF