Fixed bug #9412: config.absRefPrefix can force wrong URL when linking across domains
authorDmitry Dulepov <dmitry.dulepov@gmail.com>
Sat, 27 Sep 2008 13:34:16 +0000 (13:34 +0000)
committerDmitry Dulepov <dmitry.dulepov@gmail.com>
Sat, 27 Sep 2008 13:34:16 +0000 (13:34 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4253 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/tslib/class.tslib_content.php

index 9b712fa..ac18209 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-09-27  Dmitry Dulepov  <dmitry@typo3.org>
+
+       * Fixed bug #9412: config.absRefPrefix can force wrong URL when linking across domains
+
 2008-09-26  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #9386: Acronym plugin encoding problem
@@ -10,9 +14,6 @@
 
        * Fixed issue #9424: htmlArea RTE: Cleanup dialogue windows
 
-2008-08-30  Kasper Sk\8crh¿j  <kaspe@typo3.org>
-       * [Testing commit permissions by editing changelog.....]
-
 2008-09-23  Martin Kutschker  <masi@typo3.org>
 
        * Fixed bug #9411: Editors cannot create new translations of pages
index 35b4699..83f92b5 100755 (executable)
@@ -5252,7 +5252,8 @@ class tslib_cObj {
                $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type;
                $this->lastTypoLinkUrl = '';
                $this->lastTypoLinkTarget = '';
-               if ($link_param)        {
+               if ($link_param) {
+                       $enableLinksAcrossDomains = $GLOBALS['TSFE']->config['config']['typolinkEnableLinksAcrossDomains'];
                        $link_paramA = t3lib_div::unQuoteFilenames($link_param,true);
 
                                // Check for link-handler keyword:
@@ -5434,7 +5435,7 @@ class tslib_cObj {
                                                        // If we link across domains and page is free type shortcut, we must resolve the shortcut first!
                                                        // If we do not do it, TYPO3 will fail to (1) link proper page in RealURL/CoolURI because
                                                        // they return relative links and (2) show proper page if no RealURL/CoolURI exists when link is clicked
-                                                       if ($GLOBALS['TSFE']->config['config']['typolinkEnableLinksAcrossDomains'] && $page['doktype'] == 4 && $page['shortcut_mode'] == 0) {
+                                                       if ($enableLinksAcrossDomains && $page['doktype'] == 4 && $page['shortcut_mode'] == 0) {
                                                                $page2 = $page; // Save in case of broken destination or endless loop
                                                                $maxLoopCount = 20;     // Same as in RealURL, seems enough
                                                                while ($maxLoopCount && is_array($page) && $page['doktype'] == 4 && $page['shortcut_mode'] == 0) {
@@ -5473,7 +5474,7 @@ class tslib_cObj {
                                                        }
                                                }
                                                        // If other domain, overwrite
-                                               if (strlen($tCR_domain) && !$GLOBALS['TSFE']->config['config']['typolinkEnableLinksAcrossDomains']) {
+                                               if (strlen($tCR_domain) && !$enableLinksAcrossDomains) {
                                                        $target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget;
                                                        if ($conf['extTarget.']) {
                                                                $target = $this->stdWrap($target, $conf['extTarget.']);
@@ -5490,6 +5491,17 @@ class tslib_cObj {
                                                        $LD = $GLOBALS['TSFE']->tmpl->linkData($page,$target,$conf['no_cache'],'','',$addQueryParams,$theTypeP);
                                                        if (strlen($tCR_domain)) {
                                                                // We will add domain only if URL does not have it already.
+
+                                                               if ($enableLinksAcrossDomains) {
+                                                                       // Get rid of the absRefPrefix if necessary. absRefPrefix is applicable only
+                                                                       // to the current web site. If we have domain here it means we link across
+                                                                       // domains. absRefPrefix can contain domain name, which will screw up
+                                                                       // the link to the external domain.
+                                                                       $prefixLength = strlen($GLOBALS['TSFE']->config['config']['absRefPrefix']);
+                                                                       if (substr($LD['totalURL'], 0, $prefixLength) == $GLOBALS['TSFE']->config['config']['absRefPrefix']) {
+                                                                               $LD['totalURL'] = substr($LD['totalURL'], $prefixLength);
+                                                                       }
+                                                               }
                                                                $urlParts = parse_url($LD['totalURL']);
                                                                if ($urlParts['host'] == '') {
                                                                        $LD['totalURL'] = 'http://' . $tCR_domain . ($LD['totalURL']{0} == '/' ? '' : '/') . $LD['totalURL'];