Bug #62267
closedgetImgResource some returns urlencoded file path, sometimes not
0%
Description
Since introduction of FAL ContentObjectRenderer::getImgResource() may return either urlencoded or non-urlencoded result depending on the source file.
If the source file is not in FAL (for example, you use "import." from typo3temp or your own ext) or the source is GIFBUILDER, the third element of the returned result will not be encoded. If the file is in FAL, the returned result will be encoded (it uses getPublicUrl() from FAL). As a result you never know whether you have to urlencode $result3 or not. Try with file names that contain German characters.
Relevant pieces of code are below.
Near line 5306, where the encoded result will be set
if ($processedFileObject->isProcessed() && !isset($GLOBALS['TSFE']->tmpl->fileCache[$hash])) { $GLOBALS['TSFE']->tmpl->fileCache[$hash] = array( 0 => $processedFileObject->getProperty('width'), 1 => $processedFileObject->getProperty('height'), 2 => $processedFileObject->getExtension(), 3 => $processedFileObject->getPublicUrl(), '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, 'fileCacheHash' => $hash ); } $imageResource = $GLOBALS['TSFE']->tmpl->fileCache[$hash];
Near line 5328 (not encoded):
if (!isset($imageResource)) { $theImage = $GLOBALS['TSFE']->tmpl->getFileName($file); if ($theImage) { $gifCreator = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Imaging\\GifBuilder'); /** @var $gifCreator GifBuilder */ $gifCreator->init(); $info = $gifCreator->imageMagickConvert($theImage, 'WEB'); $info['origFile'] = $theImage; // This is needed by \TYPO3\CMS\Frontend\Imaging\GifBuilder, ln 100ff in order for the setup-array to create a unique filename hash. $info['origFile_mtime'] = @filemtime($theImage); $imageResource = $info; } }
Than in imageMagicConvert():
$output = $this->absPrefix . $this->tempPath . 'pics/' . $this->filenamePrefix . $theOutputName . '.' . $newExt; // Register temporary filename: $GLOBALS['TEMP_IMAGES_ON_PAGE'][] = $output; if ($this->dontCheckForExistingTempFile || !$this->file_exists_typo3temp_file($output, $imagefile)) { $this->imageMagickExec($imagefile, $output, $command, $frame); } if (file_exists($output)) { $info[3] = $output;
As you see, it is a plain file name, not an encoded URL.
Originally the third element was not supposed to be encoded.