Fixed encoded ampersands being replaced
authorAlexander Ebert <ebert@woltlab.com>
Wed, 5 Oct 2016 10:53:08 +0000 (12:53 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 5 Oct 2016 10:53:08 +0000 (12:53 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js

index 233f8bf4e1be8566a557c46384fac3826709f9ea..63a367fe1729ab33e90ff330f8897992ccf64b20 100644 (file)
@@ -9,7 +9,17 @@ $.Redactor.prototype.WoltLabClean = function() {
                        
                        var mpOnSet = this.clean.onSet;
                        this.clean.onSet = (function (html) {
-                               return mpOnSet.call(this, html.replace(/\u200B/g, ''));
+                               html = html.replace(/\u200B/g, '');
+                               
+                               // fix ampersands being replaced
+                               html = html.replace(/&amp;/g, '@@@WCF_AMPERSAND@@@');
+                               
+                               html = mpOnSet.call(this, html);
+                               
+                               // restore ampersands
+                               html = html.replace(/@@@WCF_AMPERSAND@@@/g, '&amp;');
+                               
+                               return html;
                        }).bind(this);
                        
                        var mpOnSync = this.clean.onSync;
@@ -17,6 +27,9 @@ $.Redactor.prototype.WoltLabClean = function() {
                                var div = elCreate('div');
                                var replacements = {};
                                
+                               // fix ampersands being replaced
+                               html = html.replace(/&amp;/g, '@@@WCF_AMPERSAND@@@');
+                               
                                if (html.indexOf('<pre') !== -1) {
                                        div.innerHTML = html;
                                        
@@ -34,6 +47,9 @@ $.Redactor.prototype.WoltLabClean = function() {
                                
                                html = mpOnSync.call(this, html);
                                
+                               // restore ampersands
+                               html = html.replace(/@@@WCF_AMPERSAND@@@/g, '&amp;');
+                               
                                div.innerHTML = html;
                                
                                elBySelAll('span', div, function (span) {