[BUGFIX] Images from non-local storages are not displayed 30/19730/2
authorSteffen Ritter <info@rs-websystems.de>
Sun, 21 Oct 2012 14:46:27 +0000 (16:46 +0200)
committerSteffen Ritter <info@rs-websystems.de>
Sun, 7 Apr 2013 10:39:26 +0000 (12:39 +0200)
The content object renderer adds absRefPrefix to all
generated image URLs, leading to incorrect URLs for
storages not relative to the siteroot. Additionally,
the URLs generated by the driver are also escaped in
ContentObjectRenderer::cImage(), leading to broken
absolute URLs.

Change-Id: I40c0a7ea55ff3a1155e7a05b1fc37da7d0cf44e4
Resolves: #42223
Releases: 6.1, 6.0
Reviewed-on: https://review.typo3.org/15837
Reviewed-by: Alexander Opitz
Reviewed-by: Nicole Cordes
Tested-by: Nicole Cordes
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
Reviewed-on: https://review.typo3.org/19730

typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index 29c1a1f..4465243 100644 (file)
@@ -1321,16 +1321,21 @@ class ContentObjectRenderer {
                $info = $this->getImgResource($file, $conf['file.']);
                $GLOBALS['TSFE']->lastImageInfo = $info;
                if (is_array($info)) {
-                       $info[3] = \TYPO3\CMS\Core\Utility\GeneralUtility::png_to_gif_by_imagemagick($info[3]);
+                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::isAllowedAbsPath(PATH_site . $info['3'])) {
+                               $source = \TYPO3\CMS\Core\Utility\GeneralUtility::rawUrlEncodeFP(\TYPO3\CMS\Core\Utility\GeneralUtility::png_to_gif_by_imagemagick($info[3]));
+                               $source = $GLOBALS['TSFE']->absRefPrefix . $source;
+                       } else {
+                               $source = $info[3];
+                       }
                        // This array is used to collect the image-refs on the page...
-                       $GLOBALS['TSFE']->imagesOnPage[] = $info[3];
+                       $GLOBALS['TSFE']->imagesOnPage[] = $source;
                        $altParam = $this->getAltParam($conf);
                        if ($conf['params'] && !isset($conf['params.'])) {
                                $params = ' ' . $conf['params'];
                        } else {
                                $params = isset($conf['params.']) ? ' ' . $this->stdWrap($conf['params'], $conf['params.']) : '';
                        }
-                       $theValue = '<img src="' . htmlspecialchars(($GLOBALS['TSFE']->absRefPrefix . \TYPO3\CMS\Core\Utility\GeneralUtility::rawUrlEncodeFP($info[3]))) . '" width="' . $info[0] . '" height="' . $info[1] . '"' . $this->getBorderAttr((' border="' . intval($conf['border']) . '"')) . $params . $altParam . (!empty($GLOBALS['TSFE']->xhtmlDoctype) ? ' /' : '') . '>';
+                       $theValue = '<img src="' . htmlspecialchars($source) . '" width="' . $info[0] . '" height="' . $info[1] . '"' . $this->getBorderAttr(' border="' . intval($conf['border']) . '"') . $params . $altParam . (!empty($GLOBALS['TSFE']->xhtmlDoctype) ? ' /' : '') . '>';
                        $linkWrap = isset($conf['linkWrap.']) ? $this->stdWrap($conf['linkWrap'], $conf['linkWrap.']) : $conf['linkWrap'];
                        if ($linkWrap) {
                                $theValue = $this->linkWrap($theValue, $linkWrap);