From 796811f46af26afca21f0ecae92e0b7083490b68 Mon Sep 17 00:00:00 2001 From: Lisa Kreitz Date: Thu, 4 Dec 2025 14:58:51 +0100 Subject: [PATCH 1/3] [TASK] Update extension for v12 or higher --- .../EventListener/TypoLinkEventListener.php | 31 ++++++++++++ Classes/Hooks/TypoLinkHandler.php | 50 ------------------- Configuration/Services.yaml | 8 +++ composer.json | 1 + ext_emconf.php | 2 +- ext_localconf.php | 6 --- 6 files changed, 41 insertions(+), 57 deletions(-) create mode 100644 Classes/EventListener/TypoLinkEventListener.php delete mode 100644 Classes/Hooks/TypoLinkHandler.php create mode 100644 Configuration/Services.yaml delete mode 100644 ext_localconf.php diff --git a/Classes/EventListener/TypoLinkEventListener.php b/Classes/EventListener/TypoLinkEventListener.php new file mode 100644 index 0000000..fac28d5 --- /dev/null +++ b/Classes/EventListener/TypoLinkEventListener.php @@ -0,0 +1,31 @@ +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/Classes/Hooks/TypoLinkHandler.php b/Classes/Hooks/TypoLinkHandler.php deleted file mode 100644 index 69c3ea1..0000000 --- a/Classes/Hooks/TypoLinkHandler.php +++ /dev/null @@ -1,50 +0,0 @@ - - * All rights reserved - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ***************************************************************/ - - - -use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; - -/** - * Class TypoLinkHandler - * - */ -class TypoLinkHandler -{ - public function postProcessTypoLink(&$parameters, ContentObjectRenderer &$parentObject) - { - if ($parameters['tagAttributes']['target'] === '_blank' && !$parameters['tagAttributes']['rel']) { - $parameters['tagAttributes']['rel'] = 'noopener'; - $parameters['finalTagParts']['aTagParams'] .= ' rel="noopener"'; - $parameters['conf']['ATagParams'] .= ' rel="noopener"'; - $parameters['finalTag'] = str_replace('target="_blank"', 'target="_blank" rel="noopener"', $parameters['finalTag']); - } - } -} 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..60a2e2b 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.x-dev" }, "extra": { "typo3/cms": { diff --git a/ext_emconf.php b/ext_emconf.php index d1b6937..ddc517b 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-13.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'; From 4a272425cd1d1d0348abd0117d958a45cb0c19c5 Mon Sep 17 00:00:00 2001 From: Lisa Kreitz Date: Thu, 4 Dec 2025 15:03:05 +0100 Subject: [PATCH 2/3] [TASK] Re add doc header --- .../EventListener/TypoLinkEventListener.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Classes/EventListener/TypoLinkEventListener.php b/Classes/EventListener/TypoLinkEventListener.php index fac28d5..e64e66e 100644 --- a/Classes/EventListener/TypoLinkEventListener.php +++ b/Classes/EventListener/TypoLinkEventListener.php @@ -4,6 +4,32 @@ namespace B13\Snipper\EventListener; +/*************************************************************** + * Copyright notice - MIT License (MIT) + * + * (c) 2019 b13 GmbH, + * David Steeb + * All rights reserved + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ***************************************************************/ + use TYPO3\CMS\Core\Attribute\AsEventListener; use TYPO3\CMS\Frontend\Event\AfterLinkIsGeneratedEvent; From c56f91902a155778f156bf0f2e9879e388a2d0ac Mon Sep 17 00:00:00 2001 From: Lisa Kreitz Date: Thu, 4 Dec 2025 15:11:29 +0100 Subject: [PATCH 3/3] [TASK] Set correct TYPO3 version for dependency --- composer.json | 2 +- ext_emconf.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 60a2e2b..c64ac8e 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +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.x-dev" + "typo3/cms-backend": "^12.4 || ^13.4 || ^14.0" }, "extra": { "typo3/cms": { diff --git a/ext_emconf.php b/ext_emconf.php index ddc517b..ffa0e50 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -13,7 +13,7 @@ 'constraints' => [ 'depends' => [ - 'typo3' => '12.4.0-13.99.99', + 'typo3' => '12.4.0-14.99.99', ], ], ];