[BUGFIX] Images from non-local storages are not displayed 37/15837/10
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:35:50 +0000 (12:35 +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
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index e91ebd2..02d2d87 100644 (file)
@@ -1324,16 +1324,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);