diff --git a/typo3/sysext/frontend/Classes/Typolink/LinkFactory.php b/typo3/sysext/frontend/Classes/Typolink/LinkFactory.php index cb3a53b43594a79c1a4cbd613313a30c885971e6..8bb1361bd3a9ba0c3e530fb8b639b5b86330084d 100644 --- a/typo3/sysext/frontend/Classes/Typolink/LinkFactory.php +++ b/typo3/sysext/frontend/Classes/Typolink/LinkFactory.php @@ -58,7 +58,11 @@ class LinkFactory implements LoggerAwareInterface if (isset($linkConfiguration['parameter.'])) { // Evaluate "parameter." stdWrap but keep additional information (like target, class and title) $linkParameterParts = $this->typoLinkCodecService->decode($linkConfiguration['parameter'] ?? ''); - $linkParameterParts['url'] = $contentObjectRenderer->stdWrap($linkParameterParts['url'], $linkConfiguration['parameter.']); + $modifiedLinkParameterString = $contentObjectRenderer->stdWrap($linkParameterParts['url'], $linkConfiguration['parameter.']); + // As the stdWrap result might contain target etc. as well again (".field = header_link") + // the result is then taken from the stdWrap and overridden if the value is not empty. + $modifiedLinkParameterParts = $this->typoLinkCodecService->decode($modifiedLinkParameterString); + $linkParameterParts = array_replace($linkParameterParts, array_filter($modifiedLinkParameterParts, 'trim')); $linkParameter = $this->typoLinkCodecService->encode($linkParameterParts); } else { $linkParameter = trim((string)($linkConfiguration['parameter'] ?? '')); diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php index d29bef5df5bfbf7a87df2d5592f255075d0abee0..b11afa82ec3aecb0cc3ec11bc2451946b00f85aa 100644 --- a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php +++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php @@ -2657,6 +2657,33 @@ class ContentObjectRendererTest extends UnitTestCase ], '<a href="http://typo3.com" class="url-class">TYPO3</a>', ], + 'Link url using stdWrap with class attribute in parameter and overridden target' => [ + 'TYPO3', + [ + 'parameter' => 'http://typo3.org default-target url-class', + 'parameter.' => [ + 'cObject' => 'TEXT', + 'cObject.' => [ + 'value' => 'http://typo3.com new-target different-url-class', + ], + ], + ], + '<a href="http://typo3.com" target="new-target" rel="noreferrer" class="different-url-class">TYPO3</a>', + ], + 'Link url using stdWrap with class attribute in parameter and overridden target and returnLast' => [ + 'TYPO3', + [ + 'parameter' => 'http://typo3.org default-target url-class', + 'parameter.' => [ + 'cObject' => 'TEXT', + 'cObject.' => [ + 'value' => 'http://typo3.com new-target different-url-class', + ], + ], + 'returnLast' => 'url', + ], + 'http://typo3.com', + ], ]; }