Neos.Neos/Classes/Fusion/ConvertUrisImplementation.php
protected function replaceLinkTargets($processedContent)
    {
        $noOpenerString = $this->fusionValue('setNoOpener') ? ' rel="noopener"' : '';
        $externalLinkTarget = trim($this->fusionValue('externalLinkTarget'));
        $resourceLinkTarget = trim($this->fusionValue('resourceLinkTarget'));
        if ($externalLinkTarget === '' && $resourceLinkTarget === '') {
            return $processedContent;
        }
        $controllerContext = $this->runtime->getControllerContext();
        $host = $controllerContext->getRequest()->getHttpRequest()->getUri()->getHost();
        $processedContent = preg_replace_callback(
            '~<a .*?href="(.*?)".*?>~i',
            function ($matches) use ($externalLinkTarget, $resourceLinkTarget, $host, $noOpenerString) {
                list($linkText, $linkHref) = $matches;
                $uriHost = parse_url($linkHref, PHP_URL_HOST);
                $target = null;
                if ($externalLinkTarget !== '' && is_string($uriHost) && $uriHost !== $host) {
                    $target = $externalLinkTarget;
                }
                if ($resourceLinkTarget !== '' && strpos($linkHref, '_Resources') !== false) {
                    $target = $resourceLinkTarget;
                }
                if ($target === null) {
                    return $linkText;
                }
                if (preg_match_all('~target="(.*?)~i', $linkText, $targetMatches)) {
                    return preg_replace('/target=".*?"/', sprintf('target="%s"%s', $target, $target === '_blank' ? $noOpenerString : ''), $linkText);
                }
                return str_replace('<a', sprintf('<a target="%s"%s', $target, $target === '_blank' ? $noOpenerString : ''), $linkText);
            },
            $processedContent
        );
        return $processedContent;
    }
protected function replaceLinkTargets($processedContent)
    {
        $noOpenerString = $this->fusionValue('setNoOpener') ? ' rel="noopener"' : '';
        $externalLinkTarget = trim($this->fusionValue('externalLinkTarget'));
        $resourceLinkTarget = trim($this->fusionValue('resourceLinkTarget'));
        if ($externalLinkTarget === '' && $resourceLinkTarget === '') {
            return $processedContent;
        }
        $controllerContext = $this->runtime->getControllerContext();
        $host = $controllerContext->getRequest()->getHttpRequest()->getUri()->getHost();
        $processedContent = preg_replace_callback(
            '~<a .*?href="(.*?)".*?>~i',
            function ($matches) use ($externalLinkTarget, $resourceLinkTarget, $host, $noOpenerString) {
                list($linkText, $linkHref) = $matches;
                $uriHost = parse_url($linkHref, PHP_URL_HOST);
                $target = null;
                if ($externalLinkTarget !== '' && is_string($uriHost) && $uriHost !== $host) {
                    $target = $externalLinkTarget;
                }
                if ($resourceLinkTarget !== '' && strpos($linkHref, '_Resources') !== false) {
                    $target = $resourceLinkTarget;
                }
                if ($target === null) {
                    return $linkText;
                }
                if (preg_match_all('~target="(.*?)~i', $linkText, $targetMatches)) {
                    return preg_replace('/target=".*?"/', sprintf('target="%s"%s', $target, $target === '_blank' ? $noOpenerString : ''), $linkText);
                }
                return str_replace('<a', sprintf('<a target="%s"%s', $target, $target === '_blank' ? $noOpenerString : ''), $linkText);
            },
            $processedContent
        );
        return $processedContent;
    }
protected function replaceLinkTargets ( $ processedContent ) { $ noOpenerString = $ this -> fusionValue ( 'setNoOpener' ) ? ' rel="noopener"' : '' ; $ externalLinkTarget = trim ( $ this -> fusionValue ( 'externalLinkTarget' ) ) ; $ resourceLinkTarget = trim ( $ this -> fusionValue ( 'resourceLinkTarget' ) ) ; if ( $ externalLinkTarget === '' && $ resourceLinkTarget === '' ) { return $ processedContent ; } $ controllerContext = $ this -> runtime -> getControllerContext ( ) ; $ host = $ controllerContext -> getRequest ( ) -> getHttpRequest ( ) -> getUri ( ) -> getHost ( ) ; $ processedContent = preg_replace_callback ( '~<a .*?href="(.*?)".*?>~i' , function ( $ matches ) use ( $ externalLinkTarget , $ resourceLinkTarget , $ host , $ noOpenerString ) { list ( $ linkText , $ linkHref ) = $ matches ; $ uriHost = parse_url ( $ linkHref , PHP_URL_HOST ) ; $ target = null ; if ( $ externalLinkTarget !== '' && is_string ( $ uriHost ) && $ uriHost !== $ host ) { $ target = $ externalLinkTarget ; } if ( $ resourceLinkTarget !== '' && strpos ( $ linkHref , '_Resources' ) !== false ) { $ target = $ resourceLinkTarget ; } if ( $ target === null ) { return $ linkText ; } if ( preg_match_all ( '~target="(.*?)~i' , $ linkText , $ targetMatches ) ) { return preg_replace ( '/target=".*?"/' , sprintf ( 'target="%s"%s' , $ target , $ target === '_blank' ? $ noOpenerString : '' ) , $ linkText ) ; } return str_replace ( '<a' , sprintf ( '<a target="%s"%s' , $ target , $ target === '_blank' ? $ noOpenerString : '' ) , $ linkText ) ; } , $ processedContent ) ; return $ processedContent ; }
Replace the target attribute of link tags in processedContent with the target
specified by externalLinkTarget and resourceLinkTarget options.
Additionally set rel="noopener" for links with target="_blank".

@param string $processedContent
@return string
Replace the target attribute of link tags in processedContent with the target specified by externalLinkTarget and resourceLinkTarget options . Additionally set rel = noopener for links with target = _blank .