diff --git a/Classes/Hooks/TypoLinkHandler.php b/Classes/EventListener/TypoLinkEventListener.php similarity index 63% rename from Classes/Hooks/TypoLinkHandler.php rename to Classes/EventListener/TypoLinkEventListener.php index 69c3ea1..e64e66e 100644 --- a/Classes/Hooks/TypoLinkHandler.php +++ b/Classes/EventListener/TypoLinkEventListener.php @@ -1,6 +1,8 @@ getLinkResult()->getAttributes(); + if ( + isset($attributes['target']) + && $attributes['target'] === '_blank' + ) { + $rel = 'noopener'; + if (isset($attributes['rel'])) { + $rel = $attributes['rel'] . ' ' . $rel; + } + $linkResult = $event->getLinkResult()->withAttribute( + 'rel', + $rel, + ); + $event->setLinkResult($linkResult); } } } diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml new file mode 100644 index 0000000..84cd1f1 --- /dev/null +++ b/Configuration/Services.yaml @@ -0,0 +1,8 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + B13\Snipper\: + resource: '../Classes/*' diff --git a/composer.json b/composer.json index 96fcd59..c64ac8e 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,7 @@ "description": "Keep external links secure by adding rel=\"noopener\" to all external typolinks.", "license": "GPL-2.0-or-later", "require": { + "typo3/cms-backend": "^12.4 || ^13.4 || ^14.0" }, "extra": { "typo3/cms": { diff --git a/ext_emconf.php b/ext_emconf.php index d1b6937..ffa0e50 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -13,7 +13,7 @@ 'constraints' => [ 'depends' => [ - 'typo3' => '9.5.0-10.99.99', + 'typo3' => '12.4.0-14.99.99', ], ], ]; diff --git a/ext_localconf.php b/ext_localconf.php deleted file mode 100644 index b24993b..0000000 --- a/ext_localconf.php +++ /dev/null @@ -1,6 +0,0 @@ -postProcessTypoLink';