[BUGFIX] Support URLs in image tag generation 63/43363/2
authorNicole Cordes <typo3@cordes.co>
Tue, 15 Sep 2015 23:29:37 +0000 (01:29 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 16 Sep 2015 13:15:15 +0000 (15:15 +0200)
FAL files may return an absolute URL depending on the driver the
storage uses. Currently the absRefPrefix is prepended automatically
to the image source without analyzing the file path. This patch ensures
the prefix is only added for local files.

Resolves: #69861
Releases: master, 6.2
Change-Id: Ida5568372817ac6e840bcc366090fe3e8a925eec
Reviewed-on: http://review.typo3.org/43363
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index fab25e0..8206c3c 100644 (file)
@@ -1669,7 +1669,11 @@ class ContentObjectRenderer {
                                if ($sourceInfo) {
                                        $sourceConfiguration['width'] = $sourceInfo[0];
                                        $sourceConfiguration['height'] = $sourceInfo[1];
-                                       $sourceConfiguration['src'] = htmlspecialchars($tsfe->absRefPrefix . $sourceInfo[3]);
+                                       $urlPrefix = '';
+                                       if (parse_url($sourceInfo[3], PHP_URL_HOST) === NULL) {
+                                               $urlPrefix = $tsfe->absRefPrefix;
+                                       }
+                                       $sourceConfiguration['src'] = htmlspecialchars($urlPrefix . $sourceInfo[3]);
                                        $sourceConfiguration['selfClosingTagSlash'] = (!empty($tsfe->xhtmlDoctype) ? ' /' : '');
 
                                        $oneSourceCollection = $this->substituteMarkerArray($sourceLayout, $sourceConfiguration, '###|###', TRUE, TRUE);
@@ -4567,7 +4571,11 @@ class ContentObjectRenderer {
                                        } else {
                                                $icon = $notFoundThumb;
                                        }
-                                       $icon = '<img src="' . htmlspecialchars($tsfe->absRefPrefix . $icon) . '"' .
+                                       $urlPrefix = '';
+                                       if (parse_url($icon, PHP_URL_HOST) === NULL) {
+                                               $urlPrefix = $tsfe->absRefPrefix;
+                                       }
+                                       $icon = '<img src="' . htmlspecialchars($urlPrefix . $icon) . '"' .
                                                        'width="' . $sizeParts[0] . '" height="' . $sizeParts[1] . '" ' .
                                                        $this->getBorderAttr(' border="0"') . '' . $this->getAltParam($conf) . ' />';
                                }
@@ -4576,7 +4584,7 @@ class ContentObjectRenderer {
                                $iconWidth = !empty($conf['icon.']['widthAttribute']) ? $conf['icon.']['widthAttribute'] : 18;
                                $conf['icon.']['heightAttribute'] = isset($conf['icon.']['heightAttribute.']) ? $this->stdWrap($conf['icon.']['heightAttribute'], $conf['icon.']['heightAttribute.']) : $conf['icon.']['heightAttribute'];
                                $iconHeight = !empty($conf['icon.']['heightAttribute']) ? $conf['icon.']['heightAttribute'] : 16;
-                               $icon = '<img src="' . htmlspecialchars(($tsfe->absRefPrefix . $icon)) . '" width="' . $iconWidth . '" height="' . $iconHeight . '"' . $this->getBorderAttr(' border="0"') . $this->getAltParam($conf) . ' />';
+                               $icon = '<img src="' . htmlspecialchars($tsfe->absRefPrefix . $icon) . '" width="' . $iconWidth . '" height="' . $iconHeight . '"' . $this->getBorderAttr(' border="0"') . $this->getAltParam($conf) . ' />';
                        }
                        if ($conf['icon_link'] && !$conf['combinedLink']) {
                                $icon = $this->wrap($icon, $theLinkWrap);