From: Stefan Galinski Date: Thu, 1 Dec 2011 17:52:15 +0000 (+0100) Subject: [BUGFIX] Shortcut redirect ignores linkVars syntax X-Git-Tag: TYPO3_4-7-0beta1~86 X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/commitdiff_plain/edd4844ad7760d7dd3deb6cba22feaf8749bd062 [BUGFIX] Shortcut redirect ignores linkVars syntax Currently the code that creates the redirect url for a shortcut page only respects the linkVars option as list of parameters without additional validation informations like it's documented in the TSRef. Unfortunatly such paramaters are completely dropped and this leads to major problems on multilanguage sites with the new shortcut redirect feature. Change-Id: I3966eedf284b06b7765f38ca07ea6cd7155babb3 Fixes: #32253 Releases: 4.7, 4.6 Reviewed-on: http://review.typo3.org/7015 Reviewed-by: Björn Pedersen Reviewed-by: Markus Klein Tested-by: Markus Klein Reviewed-by: Stefan Neufeind Reviewed-by: Wouter Wolters Reviewed-by: Tolleiv Nietsch Tested-by: Tolleiv Nietsch --- diff --git a/typo3/sysext/cms/tslib/class.tslib_fe.php b/typo3/sysext/cms/tslib/class.tslib_fe.php index 528ccd1ce909..855765ad6839 100644 --- a/typo3/sysext/cms/tslib/class.tslib_fe.php +++ b/typo3/sysext/cms/tslib/class.tslib_fe.php @@ -2683,6 +2683,50 @@ } } + /** + * Calculates and sets the internal linkVars based upon the current + * $_GET parameters and the setting "config.linkVars". + * + * @return void + */ + public function calculateLinkVars() { + $this->linkVars = ''; + $linkVars = t3lib_div::trimExplode(',', (string) $this->config['config']['linkVars']); + if (empty($linkVars)) { + return; + } + + $getData = t3lib_div::_GET(); + foreach ($linkVars as $linkVar) { + $test = $value = ''; + if (preg_match('/^(.*)\((.+)\)$/', $linkVar, $match)) { + $linkVar = trim($match[1]); + $test = trim($match[2]); + } + + if ($linkVar === '' || !isset($getData[$linkVar])) { + continue; + } + + if (!is_array($getData[$linkVar])) { + $temp = rawurlencode($getData[$linkVar]); + + if ($test !== '' && !TSpagegen::isAllowedLinkVarValue($temp, $test)) { + continue; // Error: This value was not allowed for this key + } + + $value = '&' . $linkVar . '=' . $temp; + } else { + if ($test !== '' && strcmp('array', $test)) { + continue; // Error: This key must not be an array! + } + $value = t3lib_div::implodeArrayForUrl($linkVar, $getData[$linkVar]); + } + + $this->linkVars .= $value; + } + } + /** * Redirect to target page, if the current page is a Shortcut. * @@ -2692,20 +2736,8 @@ * @return void If page is not a Shortcut, redirects and exits otherwise */ public function checkPageForShortcutRedirect() { - if (!empty($this->originalShortcutPage) && $this->originalShortcutPage['doktype'] == t3lib_pageSelect::DOKTYPE_SHORTCUT) { - $linkVars = t3lib_div::trimExplode(',', (string) $this->config['config']['linkVars']); - if (!empty($linkVars)) { - $getData = t3lib_div::_GET(); - foreach ($linkVars as $key) { - if (isset($getData[$key])) { - $value = rawurlencode($getData[$key]); - if (!empty($value)) { - $this->linkVars .= '&' . $key . '=' . $value; - } - } - } - } + $this->calculateLinkVars(); // instantiate tslib_content to generate the correct target URL /** @var $cObj tslib_cObj */ diff --git a/typo3/sysext/cms/tslib/class.tslib_pagegen.php b/typo3/sysext/cms/tslib/class.tslib_pagegen.php index bfd5874230f7..e53d3165a09d 100644 --- a/typo3/sysext/cms/tslib/class.tslib_pagegen.php +++ b/typo3/sysext/cms/tslib/class.tslib_pagegen.php @@ -138,44 +138,7 @@ class TSpagegen { } // linkVars - $linkVars = (string)$GLOBALS['TSFE']->config['config']['linkVars']; - if ($linkVars) { - $linkVarArr = explode(',',$linkVars); - - $GLOBALS['TSFE']->linkVars=''; - $GET = t3lib_div::_GET(); - - foreach ($linkVarArr as $val) { - $val = trim($val); - - if (preg_match('/^(.*)\((.+)\)$/',$val,$match)) { - $val = trim($match[1]); - $test = trim($match[2]); - } else unset($test); - - if ($val && isset($GET[$val])) { - if (!is_array($GET[$val])) { - $tmpVal = rawurlencode($GET[$val]); - - if ($test && !TSpagegen::isAllowedLinkVarValue($tmpVal,$test)) { - continue; // Error: This value was not allowed for this key - } - - $value = '&'.$val.'='.$tmpVal; - } else { - if ($test && strcmp('array',$test)) { - continue; // Error: This key must not be an array! - } - $value = t3lib_div::implodeArrayForUrl($val,$GET[$val]); - } - } else continue; - - $GLOBALS['TSFE']->linkVars.= $value; - } - unset($GET); - } else { - $GLOBALS['TSFE']->linkVars=''; - } + $GLOBALS['TSFE']->calculateLinkVars(); // dtdAllowsFrames indicates whether to use the target attribute in links $GLOBALS['TSFE']->dtdAllowsFrames = FALSE;