[BUGFIX] Do not prefix FAL file links with absRefPrefix 15/52615/2
authorHelmut Hummel <typo3@helhum.io>
Thu, 6 Apr 2017 20:31:36 +0000 (22:31 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 27 Apr 2017 09:16:01 +0000 (11:16 +0200)
When using an external FAL storage the public URLs of files contain a scheme.
Check for the scheme before prefixing with absRefPrefix
in file link builder.

Resolves: #80740
Releases: 7.6, master
Change-Id: I98c1027931f6c4c05561e35d1d7938aefd66eda0
Reviewed-on: https://review.typo3.org/52615
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index 0227a0d..07f17da 100644 (file)
@@ -6514,10 +6514,15 @@ class ContentObjectRenderer
 
                 // check if the file exists or if a / is contained (same check as in detectLinkType)
                 if (file_exists(rawurldecode($splitLinkParam[0])) || strpos($linkParameter, '/') !== false) {
+                    $fileUri = $linkParameter;
                     if ($linktxt === '') {
                         $linktxt = $this->parseFunc(rawurldecode($linkParameter), ['makelinks' => 0], '< lib.parseFunc');
                     }
-                    $fileUri = (!StringUtility::beginsWith($linkParameter, '/') ? $GLOBALS['TSFE']->absRefPrefix : '') . $linkParameter;
+                    if (!StringUtility::beginsWith($linkParameter, '/')
+                        && parse_url($linkParameter, PHP_URL_SCHEME) === null
+                    ) {
+                        $fileUri = $tsfe->absRefPrefix . $fileUri;
+                    }
                     $this->lastTypoLinkUrl = $this->processUrl(UrlProcessorInterface::CONTEXT_FILE, $fileUri, $conf);
                     $this->lastTypoLinkUrl = $this->forceAbsoluteUrl($this->lastTypoLinkUrl, $conf);
                     $target = isset($conf['fileTarget']) ? $conf['fileTarget'] : $tsfe->fileTarget;