[BUGFIX] RTE: Style config option allowedClasses not correctly handled 47/36147/3
authorStanislas Rolland <typo3@sjbr.ca>
Tue, 20 Jan 2015 20:31:21 +0000 (15:31 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Tue, 20 Jan 2015 20:34:07 +0000 (21:34 +0100)
RTE configuration properties
buttons.blockstyle.tags.[ tag-name ].allowedClasses and
buttons.textstyle.tags.[ tag-name ].allowedClasses
are not correctly processed.
Some classes configured for a tag may not appear in the
style dropdown.

Releases: 6.2
Resolves: #64389
Change-Id: I72652996ae121c42573c9da8bcf1a16918c41401
Reviewed-on: http://review.typo3.org/36147
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js

index 8d9af70..79f56c4 100644 (file)
@@ -24,16 +24,12 @@ HTMLArea.BlockStyle = Ext.extend(HTMLArea.Plugin, {
                this.tags = (this.pageTSconfiguration && this.pageTSconfiguration.tags) ? this.pageTSconfiguration.tags : {};
                var allowedClasses;
                for (var tagName in this.tags) {
-                       if (this.tags.hasOwnProperty(tagName)) {
-                               if (this.tags[tagName].allowedClasses) {
-                                       allowedClasses = this.tags[tagName].allowedClasses.trim().split(",");
-                                       for (var cssClass in allowedClasses) {
-                                               if (allowedClasses.hasOwnProperty(cssClass)) {
-                                                       allowedClasses[cssClass] = allowedClasses[cssClass].trim().replace(/\*/g, ".*");
-                                               }
-                                       }
-                                       this.tags[tagName].allowedClasses = new RegExp( "^(" + allowedClasses.join("|") + ")$", "i");
+                       if (this.tags[tagName].allowedClasses) {
+                               allowedClasses = this.tags[tagName].allowedClasses.trim().split(",");
+                               for (var i = allowedClasses.length; --i >= 0;) {
+                                       allowedClasses[i] = allowedClasses[i].trim().replace(/\*/g, ".*");
                                }
+                               this.tags[tagName].allowedClasses = new RegExp( "^(" + allowedClasses.join("|") + ")$", "i");
                        }
                }
                this.showTagFreeClasses = this.pageTSconfiguration ? this.pageTSconfiguration.showTagFreeClasses : false;
index 088d696..74a8cb5 100644 (file)
@@ -27,16 +27,12 @@ HTMLArea.TextStyle = Ext.extend(HTMLArea.Plugin, {
                this.tags = (this.pageTSconfiguration && this.pageTSconfiguration.tags) ? this.pageTSconfiguration.tags : {};
                var allowedClasses;
                for (var tagName in this.tags) {
-                       if (this.tags.hasOwnProperty(tagName)) {
-                               if (this.tags[tagName].allowedClasses) {
-                                       allowedClasses = this.tags[tagName].allowedClasses.trim().split(",");
-                                       for (var cssClass in allowedClasses) {
-                                               if (allowedClasses.hasOwnProperty(cssClass)) {
-                                                       allowedClasses[cssClass] = allowedClasses[cssClass].trim().replace(/\*/g, ".*");
-                                               }
-                                       }
-                                       this.tags[tagName].allowedClasses = new RegExp( "^(" + allowedClasses.join("|") + ")$", "i");
+                       if (this.tags[tagName].allowedClasses) {
+                               allowedClasses = this.tags[tagName].allowedClasses.trim().split(",");
+                               for (var i = allowedClasses.length; --i >= 0;) {
+                                       allowedClasses[i] = allowedClasses[i].trim().replace(/\*/g, ".*");
                                }
+                               this.tags[tagName].allowedClasses = new RegExp( "^(" + allowedClasses.join("|") + ")$", "i");
                        }
                }
                this.showTagFreeClasses = this.pageTSconfiguration ? this.pageTSconfiguration.showTagFreeClasses : false;