Issue Bug Resolved

#35069addQueryString.exclude should take precedence over config.linkVars

Anonymous 03/21/12, 10:14 updated 09/04/26, 12:00

Description

Getting rid of an URL parameter when creating a typolink seems to be impossible using addQueryString.exclude when the parameter is set to the list of config.linkVars.

config.linkVars = L(int)
somelink = TEXT
someline {
    value = this link keeps the L parameter
    typolink {
        parameter.data = TSFE:id
        addQueryString = 1
        addQueryString.method = GET
        addQueryString.exclude = L
    }
}

the generated link will contain the parameter L whenever it is set in the calling URL.

the following seems to kinda work as a workaround when RealURL is active and configured to drop an empty L:

somelink.typolink.additionalParams = &L=

the problem can be tracked down to the method linkData() in class.t3lib_tstemplate.php where all the linkVars are being added to the URL:

1379                         // linkVars
1380                 if ($GLOBALS['TSFE']->config['config']['uniqueLinkVars']) {
1381                         if ($addParams) {
1382                                 $LD['linkVars'] = t3lib_div::implodeArrayForUrl('', t3lib_div::explodeUrl2Array($GLOBALS['TSFE']->linkVars . $addParams), '', FALSE, TRUE);
1383                         } else {
1384                                 $LD['linkVars'] = $GLOBALS['TSFE']->linkVars;
1385                         }
1386                 } else {
1387                         $LD['linkVars'] = $GLOBALS['TSFE']->linkVars . $addParams;
1388                 }

linkData() is being called from class.tslib_content.php AFTER gotten rid of the unwanted parameter:

5745       // Query Params:
5746       $addQueryParams = $conf['addQueryString'] ? $this->getQueryArguments($conf['addQueryString.']) : '';
5747       $addQueryParams .= isset($conf['additionalParams.'])
5748              ? trim($this->stdWrap($conf['additionalParams'], $conf['additionalParams.']))
5749              : trim($conf['additionalParams']);
5750       if ($addQueryParams == '&' || substr($addQueryParams, 0, 1) != '&') {
5751               $addQueryParams = '';
5752       }

...

5885        } else { // Internal link or current domain's linking scheme should be used
5886              if ($forceTarget) {
5887                      $target = $forceTarget;
5888              }
5889              $LD = $GLOBALS['TSFE']->tmpl->linkData(
5890                    $page,
5891                    $target,
5892                    $conf['no_cache'],
5893                    '',
5894                    '',
5895                    $addQueryParams,
5896                    $theTypeP,
5897                    $targetDomain
5898              );

i encountered this behaviour in TYPO3 4.5, the source above is from 4.7 though.

Reviews 2

History 1215

  1. Jigal van Hemert changed category status New Accepted target version <span data-processor="relativetime" data-value="2012-03-21T22:23:44+00:00" > 03/21/12, 22:23 </span>

  2. Helmut Hummel commented and changed target version Complexity hard <span data-processor="relativetime" data-value="2012-03-25T19:02:26+00:00" > 03/25/12, 19:02 </span>

    Changing that in released version might cause unexpected results. I would not risk to break sites by changing the behavior, but rather change it for a new version.

  3. Mathias Schreiber changed subject addQueryString.exclude does not work for config.linkVars addQueryString.exclude should take precedence over config.linkVars target version Is Regression 0 <span data-processor="relativetime" data-value="2015-01-15T13:00:32+00:00" > 01/15/15, 13:00 </span>

  4. Alex Kellner commented <span data-processor="relativetime" data-value="2018-11-20T11:58:58+00:00" > 11/20/18, 11:58 </span>

    This is still a thing in the latest TYPO3 8.7 version.

  5. Oliver Hader commented <span data-processor="relativetime" data-value="2021-12-16T13:58:47+00:00" > 12/16/21, 13:58 </span>

    Please also see

    TYPO3-PSA-2021-003: Mitigation of Cache Poisoning Caused by Untrusted URL Query Parameters
    https://typo3.org/security/advisory/typo3-psa-2021-003

  6. Oliver Hader commented <span data-processor="relativetime" data-value="2021-12-16T13:59:45+00:00" > 12/16/21, 13:59 </span>

    Besides that, I guess the original report is still a topic in TYPO3 v11.

  7. Gerrit Code Review pushed patch set 1 for main to change 76606 status Accepted Under Review <span data-processor="relativetime" data-value="2022-11-15T12:23:44+00:00" > 11/15/22, 12:23 </span>

  8. Benjamin Kott commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-09-04T12:00:10+00:00" > 09/04/26, 12:00 </span>

    Applied in changeset commit:94c91020bd0c0ba5837d893c727888c743e50815.