From 8e17482f494861b7a0e3cf42a9d84075585bf7ea Mon Sep 17 00:00:00 2001
From: Benjamin Franzke <ben@bnf.dev>
Date: Fri, 22 Sep 2023 09:22:18 +0200
Subject: [PATCH] [BUGFIX] Preserve allowedClasses (non classesAnchor) in link
 browser

RTE link classes that are configured via
`buttons.link.properties.class.allowedClasses` are selectable
in all link types in the link browser.

Specific classes can be limited to specific link types with a
separate configuration option `classesAnchor.{id}.type|class`.
When such limits are active, classes that are *not* configured to
associated/limited to a specfic type, remain listed and available
for *all* link types.

When an existing link with such type of globally allowed class is opened
its value was cleared because it was not defined in the set of limits.
This was an inconsistency as the link class was still selectable, but
the selection was removed upon reoping such link. Such values are now
preserved.

Resolves: #102005
Releases: main, 12.4, 11.5
Change-Id: I0ad4273819f1d5a8e06f587b94fefb4598a07c13
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81169
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
---
 .../rte_ckeditor/Classes/Controller/BrowseLinksController.php    | 1 +
 1 file changed, 1 insertion(+)

diff --git a/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php b/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php
index 53d16a88edca..9e9ae44dc9b8 100644
--- a/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php
+++ b/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php
@@ -212,6 +212,7 @@ class BrowseLinksController extends AbstractLinkBrowserController
                 }
             }
             if (isset($this->linkAttributeValues['class'])
+                && in_array($this->linkAttributeValues['class'], $classesAnchor['all'])
                 && isset($classesAnchor[$this->displayedLinkHandlerId])
                 && !in_array($this->linkAttributeValues['class'], $classesAnchor[$this->displayedLinkHandlerId], true)
             ) {
-- 
GitLab