diff --git a/typo3/sysext/fluid/Tests/Functional/ViewHelpers/Link/TypolinkViewHelperTest.php b/typo3/sysext/fluid/Tests/Functional/ViewHelpers/Link/TypolinkViewHelperTest.php index 45661d3236d8..232f06255b3d 100644 --- a/typo3/sysext/fluid/Tests/Functional/ViewHelpers/Link/TypolinkViewHelperTest.php +++ b/typo3/sysext/fluid/Tests/Functional/ViewHelpers/Link/TypolinkViewHelperTest.php @@ -17,7 +17,11 @@ namespace TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Link; +use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder; use TYPO3\CMS\Core\Database\ConnectionPool; +use TYPO3\CMS\Core\Http\ServerRequest; +use TYPO3\CMS\Core\Routing\PageArguments; +use TYPO3\CMS\Core\Site\Entity\Site; use TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait; use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory; use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest; @@ -43,6 +47,23 @@ final class TypolinkViewHelperTest extends FunctionalTestCase ], ]; + protected function setUp(): void + { + parent::setUp(); + $request = new ServerRequest('http://localhost/'); + $request = $request->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_FE); + $request = $request->withAttribute('routing', new PageArguments(1, '0', [])); + $request = $request->withAttribute('site', new Site( + 'site', + 1, + [ + 'base' => 'http://localhost/', + 'languages' => [], + ] + )); + $GLOBALS['TYPO3_REQUEST'] = $request; + } + public static function renderDataProvider(): array { return [ diff --git a/typo3/sysext/frontend/Classes/Typolink/ExternalUrlLinkBuilder.php b/typo3/sysext/frontend/Classes/Typolink/ExternalUrlLinkBuilder.php index 4d1d8b9674fa..549b93efc157 100644 --- a/typo3/sysext/frontend/Classes/Typolink/ExternalUrlLinkBuilder.php +++ b/typo3/sysext/frontend/Classes/Typolink/ExternalUrlLinkBuilder.php @@ -27,6 +27,10 @@ class ExternalUrlLinkBuilder extends AbstractTypolinkBuilder public function build(array &$linkDetails, string $linkText, string $target, array $conf): LinkResultInterface { $url = $linkDetails['url'] ?? ''; + // issue https://forge.typo3.org/issues/101083 forces absolute path URLs + // like `/path/some-file.png` to be handled as external URL, and that's + // why the URL is forced to contain a fully qualified domain name as well + $url = $this->forceAbsoluteUrl($url, $conf); $linkText = $this->encodeFallbackLinkTextIfLinkTextIsEmpty($linkText, $url); return (new LinkResult(LinkService::TYPE_URL, (string)$url)) ->withLinkConfiguration($conf)