[BUGFIX] typolink prepends wrong domain when using url scheme
authorDmitry Dulepov <dmitry@typo3.org>
Thu, 17 Nov 2011 16:03:43 +0000 (18:03 +0200)
committerOliver Hader <oliver@typo3.org>
Tue, 24 Jan 2012 09:25:38 +0000 (10:25 +0100)
tslib_cObj::typoLink() uses a wrong domain if the target page
has a domain record and a URL scheme, which is different to
current. It prepends a current domain instead of the target
domain of the page.

Change-Id: Iedf2ade4707f41f10a1989b753cb5fc0dcf978a1
Resolves: #31771
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/6710
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/cms/tslib/class.tslib_content.php

index 0618fcd..0e555ad 100644 (file)
@@ -5805,17 +5805,17 @@ class tslib_cObj {
                                                        if (isset($conf['forceAbsoluteUrl.']['scheme']) && $conf['forceAbsoluteUrl.']['scheme']) {
                                                                $absoluteUrlScheme = $conf['forceAbsoluteUrl.']['scheme'];
                                                        } elseif ($page['url_scheme'] > 0) {
-                                                               $absoluteUrlScheme = ((int) $page['url_scheme'] === t3lib_utility_http::SCHEME_HTTP) ? 'http' : 'https';
+                                                               $absoluteUrlScheme = ((int)$page['url_scheme'] === t3lib_utility_http::SCHEME_HTTP) ? 'http' : 'https';
                                                        }
 
                                                                // If no domain records are defined, use current domain:
-                                                       if ($targetDomain === '' && $conf['forceAbsoluteUrl'] ||
-                                                                       $absoluteUrlScheme !== parse_url(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME)) {
+                                                       $currentUrlScheme = parse_url(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'), PHP_URL_SCHEME);
+                                                       if ($targetDomain === '' && ($conf['forceAbsoluteUrl'] || $absoluteUrlScheme !== $currentUrlScheme)) {
                                                                $targetDomain = $currentDomain;
                                                        }
 
-                                                               // If go for an absolute link, add site_path if it's not taken care about by absRefPrefix
-                                                       if (!$GLOBALS['TSFE']->config['config']['absRefPrefix'] && $targetDomain !== '') {
+                                                               // If go for an absolute link, add site path if it's not taken care about by absRefPrefix
+                                                       if (!$GLOBALS['TSFE']->config['config']['absRefPrefix'] && $targetDomain == $currentDomain) {
                                                                $targetDomain = $currentDomain . rtrim(t3lib_div::getIndpEnv('TYPO3_SITE_PATH'), '/');
                                                        }
                                                }