Skip to content

Commit

Permalink
[BUGFIX] Allow to add type=0 to typolink syntax
Browse files Browse the repository at this point in the history
In previous versions, it was possible to link
to type=0 via "4,0,&param=2" where this was
stripped away, as the old syntax with the third
parameter was not supported anymore.

The patch changes the "empty()" to "isset()"
and explicitly sets the type parameter again.

Resolves: #81226
Releases: master, 9.5, 8.7
Change-Id: I5d19c38c90571f6686e7121dac638342783237ec
Reviewed-on: https://review.typo3.org/59299
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
  • Loading branch information
bmack authored and georgringer committed Jan 1, 2019
1 parent 9e7f094 commit 6bdfd7e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Expand Up @@ -174,6 +174,7 @@ protected function resolvePageRelatedParameters(string $data): array
$result['pageuid'] = 'current';
$result['fragment'] = substr($data, 1);
} elseif (strpos($data, ',') !== false) {
$data = rtrim($data, ',');
list($result['pageuid'], $result['pagetype']) = explode(',', $data, 2);
} elseif (strpos($data, '/') !== false) {
$data = explode('/', trim($data, '/'));
Expand Down
3 changes: 2 additions & 1 deletion typo3/sysext/core/Classes/LinkHandling/PageLinkHandler.php
Expand Up @@ -42,7 +42,8 @@ public function asString(array $parameters): string
$urn .= '?uid=' . $parameters['pageuid'];
}
$urn = rtrim($urn, ':');
if (!empty($parameters['pagetype'])) {
// Page type is set and not empty (= "0" in this case means it is not empty)
if (isset($parameters['pagetype']) && strlen((string)$parameters['pagetype']) > 0) {
$urn .= '&type=' . $parameters['pagetype'];
}
if (!empty($parameters['parameters'])) {
Expand Down
Expand Up @@ -76,6 +76,27 @@ public function resolveParametersForNonFilesDataProvider(): array
],
't3://page?uid=13&type=31&unbel=ievable#uncool'
],
'page with type and parameters as another parameter and fragment - old style' => [
'13,31,&unbel=ievable&but=possibly#uncool',
[
'type' => LinkService::TYPE_PAGE,
'pageuid' => '13',
'pagetype' => '31',
'parameters' => 'unbel=ievable&but=possibly',
'fragment' => 'uncool'
],
't3://page?uid=13&type=31&unbel=ievable&but=possibly#uncool'
],
'page with type and parameters as third parameter and explicitly allow type=0' => [
'1,0,&param=2',
[
'type' => LinkService::TYPE_PAGE,
'pageuid' => '1',
'pagetype' => '0',
'parameters' => 'param=2',
],
't3://page?uid=1&type=0&param=2'
],
'page with alias - old style' => [
'alias13',
[
Expand Down

0 comments on commit 6bdfd7e

Please sign in to comment.