diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php index 938dafd72b8868afb44434ae0e7693c043afb06c..4333cb688f3e436561e871ab405d7c1f83096883 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php @@ -1374,6 +1374,7 @@ class ContentObjectRenderer implements LoggerAwareInterface $a2 = '</a>'; $this->getTypoScriptFrontendController()->setJS('openPic'); } else { + $conf['linkParams.']['directImageLink'] = (bool)$conf['directImageLink']; $conf['linkParams.']['parameter'] = $url; $string = $this->typoLink($string, $conf['linkParams.']); } diff --git a/typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php b/typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php index fdd147a33e08d063af555861ad1df492c50ace72..6a92933a4ff4081c8d7b1a9ce2de162b49142f28 100644 --- a/typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php +++ b/typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php @@ -183,7 +183,7 @@ abstract class AbstractTypolinkBuilder $target = ''; if (isset($conf[$name])) { $target = $conf[$name]; - } elseif ($targetAttributeAllowed) { + } elseif ($targetAttributeAllowed && !$conf['directImageLink']) { $target = $fallbackTarget; } if (isset($conf[$name . '.']) && $conf[$name . '.']) { diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php index 90730aa3e539707616b412f8d6f61d59e7e88083..b8ad463740a4a7308600fde48a7eefe1ff731c36 100644 --- a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php +++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php @@ -2658,6 +2658,7 @@ class ContentObjectRendererTest extends UnitTestCase 'constants' => '1', ], 'typolink.' => [ + 'directImageLink' => false, 'extTarget.' => [ 'override' => '', ], @@ -2739,6 +2740,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to url' => [ 'TYPO3', [ + 'directImageLink' => false, 'parameter' => 'http://typo3.org', ], '<a href="http://typo3.org">TYPO3</a>', @@ -2746,6 +2748,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to url without schema' => [ 'TYPO3', [ + 'directImageLink' => false, 'parameter' => 'typo3.org', ], '<a href="http://typo3.org">TYPO3</a>', @@ -2753,6 +2756,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to url without link text' => [ '', [ + 'directImageLink' => false, 'parameter' => 'http://typo3.org', ], '<a href="http://typo3.org">http://typo3.org</a>', @@ -2794,6 +2798,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to url with script tag' => [ '', [ + 'directImageLink' => false, 'parameter' => 'http://typo3.org<script>alert(123)</script>', ], '<a href="http://typo3.org<script>alert(123)</script>">http://typo3.org<script>alert(123)</script></a>', @@ -3006,6 +3011,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to file' => [ 'My file', [ + 'directImageLink' => false, 'parameter' => 'fileadmin/foo.bar', ], '<a href="fileadmin/foo.bar">My file</a>', @@ -3013,6 +3019,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to file without link text' => [ '', [ + 'directImageLink' => false, 'parameter' => 'fileadmin/foo.bar', ], '<a href="fileadmin/foo.bar">fileadmin/foo.bar</a>', @@ -3087,6 +3094,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to file with script tag in name' => [ '', [ + 'directImageLink' => false, 'parameter' => 'fileadmin/<script>alert(123)</script>', ], '<a href="fileadmin/<script>alert(123)</script>">fileadmin/<script>alert(123)</script></a>', @@ -3139,6 +3147,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to file' => [ 'My file', [ + 'directImageLink' => false, 'parameter' => 'fileadmin/foo.bar', ], '/', @@ -3147,6 +3156,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to file with longer absRefPrefix' => [ 'My file', [ + 'directImageLink' => false, 'parameter' => 'fileadmin/foo.bar', ], '/sub/', @@ -3155,6 +3165,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to absolute file' => [ 'My file', [ + 'directImageLink' => false, 'parameter' => '/images/foo.bar', ], '/', @@ -3163,6 +3174,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to absolute file with longer absRefPrefix' => [ 'My file', [ + 'directImageLink' => false, 'parameter' => '/images/foo.bar', ], '/sub/', @@ -3171,6 +3183,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to absolute file with identical longer absRefPrefix' => [ 'My file', [ + 'directImageLink' => false, 'parameter' => '/sub/fileadmin/foo.bar', ], '/sub/', @@ -3179,6 +3192,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to file with empty absRefPrefix' => [ 'My file', [ + 'directImageLink' => false, 'parameter' => 'fileadmin/foo.bar', ], '', @@ -3187,6 +3201,7 @@ class ContentObjectRendererTest extends UnitTestCase 'Link to absolute file with empty absRefPrefix' => [ 'My file', [ + 'directImageLink' => false, 'parameter' => '/fileadmin/foo.bar', ], '', diff --git a/typo3/sysext/frontend/Tests/Unit/Typolink/AbstractTypolinkBuilderTest.php b/typo3/sysext/frontend/Tests/Unit/Typolink/AbstractTypolinkBuilderTest.php index d4d095cb0964e9445f3eb6dfcd6055428a5c387e..fc7d5891db88cd154a88f69e5dfd5bc4b6502c39 100644 --- a/typo3/sysext/frontend/Tests/Unit/Typolink/AbstractTypolinkBuilderTest.php +++ b/typo3/sysext/frontend/Tests/Unit/Typolink/AbstractTypolinkBuilderTest.php @@ -252,7 +252,7 @@ class AbstractTypolinkBuilderTest extends UnitTestCase 'Else from fallback, if not $respectFrameSetOption ...' => [ $fallback, - [], + ['directImageLink' => false], $targetName, false, // $respectFrameSetOption false $fallback, @@ -261,7 +261,7 @@ class AbstractTypolinkBuilderTest extends UnitTestCase ' ... or no doctype ... ' => [ $fallback, - [], + ['directImageLink' => false], $targetName, true, $fallback, @@ -270,7 +270,7 @@ class AbstractTypolinkBuilderTest extends UnitTestCase ' ... or doctype xhtml_trans... ' => [ $fallback, - [], + ['directImageLink' => false], $targetName, true, $fallback, @@ -279,7 +279,7 @@ class AbstractTypolinkBuilderTest extends UnitTestCase ' ... or doctype xhtml_basic... ' => [ $fallback, - [], + ['directImageLink' => false], $targetName, true, $fallback, @@ -288,7 +288,7 @@ class AbstractTypolinkBuilderTest extends UnitTestCase ' ... or doctype html5... ' => [ $fallback, - [], + ['directImageLink' => false], $targetName, true, $fallback,