diff --git a/typo3/sysext/rtehtmlarea/Classes/Controller/BrowseLinksController.php b/typo3/sysext/rtehtmlarea/Classes/Controller/BrowseLinksController.php
index ac3166ac059dce8279d53f686b4743613ddf1e83..12df3c3a4b4b964680308e0a6d80a54dbebceeca 100644
--- a/typo3/sysext/rtehtmlarea/Classes/Controller/BrowseLinksController.php
+++ b/typo3/sysext/rtehtmlarea/Classes/Controller/BrowseLinksController.php
@@ -292,6 +292,12 @@ class BrowseLinksController extends AbstractLinkBrowserController
                     }
                 }
             }
+            if (isset($this->linkAttributeValues['class'])
+                && isset($classesAnchor[$this->displayedLinkHandlerId])
+                && !in_array($this->linkAttributeValues['class'], $classesAnchor[$this->displayedLinkHandlerId], true)
+            ) {
+                unset($this->linkAttributeValues['class']);
+            }
             // Constructing the class selector options
             foreach ($classesAnchorArray as $class) {
                 if (!in_array($class, $classesAnchor['all']) || in_array($class, $classesAnchor['all']) && is_array($classesAnchor[$this->displayedLinkHandlerId]) && in_array($class, $classesAnchor[$this->displayedLinkHandlerId])) {