Strip background-color from pasted content
authorAlexander Ebert <ebert@woltlab.com>
Sat, 7 Mar 2015 22:43:19 +0000 (23:43 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 7 Mar 2015 22:43:19 +0000 (23:43 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js

index 81f4b4d71f7bc5be33715b792c1af2df53d765b7..adfee4506dc2d0919bd86b5e3a85ef41d14bddad 100644 (file)
@@ -1509,6 +1509,20 @@ RedactorPlugins.wbbcode = function() {
                        html = html.replace(/\[size=(\d+)\]/g, '<p><span style="font-size: $1pt">');
                        html = html.replace(/\[\/size\]/g, '</span></p>');
                        
+                       // strip background-color
+                       html = html.replace(/style="([^"]+)"/, function(match, inlineStyles) {
+                               var $parts = inlineStyles.split(';');
+                               var $styles = [ ];
+                               for (var $i = 0, $length = $parts.length; $i < $length; $i++) {
+                                       var $part = $parts[$i];
+                                       if (!$part.match(/^\s*background-color/)) {
+                                               $styles.push($part);
+                                       }
+                               }
+                               
+                               return 'style="' + $styles.join(';') + '"';
+                       });
+                       
                        WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'afterPaste', { html: html });
                        
                        return html;