Bug #31771

Wrong "targetDomain" in tslib_cObj::typolink with sys_domain records and different url sheme

Added by Jaume Prat over 1 year ago. Updated over 1 year ago.

Status:Resolved Start date:2011-11-12
Priority:Must have Due date:
Assignee:- % Done:

100%

Category:-
Target version:4.5.11
TYPO3 Version:4.6 Complexity:medium
PHP Version:5.3
Votes: 2 (View)

Description

If you generate a link with "tslib_cObj::typolink" to a page which has a different domain, typolink() loads the matching domain from sys_domain. But if the target page has a different url scheme (set in page settings) than the current rendered page, then always the current domain will be used!

You can find this issue in line 5788-5792 in "class.tslib_content.php":

// 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)) {
    $targetDomain = $currentDomain;
}

You have to check for a empty $targetDomain if the target-scheme is different too! Otherwise the correct targetDomain will always be overwritten with the current domain:

You can fix it with some braces to check always for a empty targetDomain:

// 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))) {
    $targetDomain = $currentDomain;
}

Associated revisions

Revision a4fbcc84
Added by Dmitry Dulepov over 1 year ago

[BUGFIX] typolink prepends wrong domain when using url scheme

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: I1b7f1248f8b62bdaae0adeb114c29f42b146daa4
Resolves: #31771
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/6708
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
Reviewed-by: Markus Klein
Reviewed-by: Dominik Mathern
Tested-by: Dominik Mathern
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter

Revision 80c03a05
Added by Dmitry Dulepov over 1 year ago

[BUGFIX] typolink prepends wrong domain when using url scheme

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

Revision ccd2ebe8
Added by Dmitry Dulepov over 1 year ago

[BUGFIX] typolink prepends wrong domain when using url scheme

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: I11d21d19731c8d5b9337dfef773cb43484a0b291
Resolves: #31771
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/6709
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader

History

Updated by Steffen Ritter over 1 year ago

  • Status changed from New to Accepted

I know about it - stumbled across it myself...
Problem is: we would need a systematic rewrite of the typolink function...

Updated by Steffen Gebert over 1 year ago

But that's such an obvious bug that has to be fixed - independent of a rewrite of typolink.

Updated by Steffen Ritter over 1 year ago

Steffen Gebert wrote:

But that's such an obvious bug that has to be fixed - independent of a rewrite of typolink.

if you see no side effects... I fear about them...
It seems obvious, aber there must have been a reason, to do it like it has been done...

This should be tested in complex multi-domain installations for some time before including it into an release? don't you think so?

Could you give it a try at the FW sites? I would test it within the instances I had the problem myself hoping nothing else would break.

Updated by Dmitry Dulepov over 1 year ago

The proposed change would not work in all cases. The next lines are:

// 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 !== '') {
    $targetDomain = $currentDomain . rtrim(t3lib_div::getIndpEnv('TYPO3_SITE_PATH'), '/');
}

So the target domain will be overwritten by the current domain if absRefPrefix is not set.

Updated by Mr. Hudson over 1 year ago

  • Status changed from Accepted to Under Review

Patch set 1 of change I1b7f1248f8b62bdaae0adeb114c29f42b146daa4 has been pushed to the review server.
It is available at http://review.typo3.org/6708

Updated by Mr. Hudson over 1 year ago

Patch set 1 of change I11d21d19731c8d5b9337dfef773cb43484a0b291 has been pushed to the review server.
It is available at http://review.typo3.org/6709

Updated by Mr. Hudson over 1 year ago

Patch set 1 of change Iedf2ade4707f41f10a1989b753cb5fc0dcf978a1 has been pushed to the review server.
It is available at http://review.typo3.org/6710

Updated by Mr. Hudson over 1 year ago

Patch set 2 of change I1b7f1248f8b62bdaae0adeb114c29f42b146daa4 has been pushed to the review server.
It is available at http://review.typo3.org/6708

Updated by Mr. Hudson over 1 year ago

Patch set 2 of change I11d21d19731c8d5b9337dfef773cb43484a0b291 has been pushed to the review server.
It is available at http://review.typo3.org/6709

Updated by Mr. Hudson over 1 year ago

Patch set 2 of change Iedf2ade4707f41f10a1989b753cb5fc0dcf978a1 has been pushed to the review server.
It is available at http://review.typo3.org/6710

Updated by Mr. Hudson over 1 year ago

Patch set 3 of change Iedf2ade4707f41f10a1989b753cb5fc0dcf978a1 has been pushed to the review server.
It is available at http://review.typo3.org/6710

Updated by Steffen Ritter over 1 year ago

  • Target version set to 4.7.0-alpha1

Updated by Oliver Hader over 1 year ago

  • Target version changed from 4.7.0-alpha1 to 4.7.0-alpha2

Updated by Gerrit Code Review over 1 year ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/6708

Updated by Gerrit Code Review over 1 year ago

Patch set 3 for branch TYPO3_4-6 has been pushed to the review server.
It is available at http://review.typo3.org/6709

Updated by Gerrit Code Review over 1 year ago

Patch set 4 for branch TYPO3_4-5 has been pushed to the review server.
It is available at http://review.typo3.org/6710

Updated by Dmitry Dulepov over 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Updated by Ernesto Baschny over 1 year ago

  • Target version changed from 4.7.0-alpha2 to 4.5.11

Also available in: Atom PDF