Improved handling of ampersands
authorAlexander Ebert <ebert@woltlab.com>
Mon, 21 Aug 2017 11:30:38 +0000 (13:30 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 21 Aug 2017 11:30:38 +0000 (13:30 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js

index a104fa9a334075583a7e5d8b91a528293a1bd842..cb7906e4a6c00e3f9b9e216dedcde1f66b788fc2 100644 (file)
@@ -8,12 +8,16 @@ $.Redactor.prototype.WoltLabClean = function() {
                                html = html.replace(/\u200B/g, '');
                                
                                // fix ampersands being replaced
-                               html = html.replace(/&amp;/g, '@@@WCF_AMPERSAND@@@');
+                               //html = html.replace(/&amp;/g, '@@@WCF_AMPERSAND@@@');
+                               html = html.replace(/&amp;amp;/g, '@@@WCF_LITERAL_AMP@@@');
+                               html = html.replace(/&amp;/g, '&amp;WCF_AMPERSAND&amp;');
                                
                                html = mpOnSet.call(this, html);
                                
                                // restore ampersands
-                               html = html.replace(/@@@WCF_AMPERSAND@@@/g, '&amp;');
+                               //html = html.replace(/@@@WCF_AMPERSAND@@@/g, '&amp;');
+                               html = html.replace(/&amp;WCF_AMPERSAND&amp;/g, '&amp;');
+                               html = html.replace(/@@@WCF_LITERAL_AMP@@@/, '&amp;amp;');
                                
                                var div = elCreate('div');
                                div.innerHTML = html;
@@ -77,12 +81,14 @@ $.Redactor.prototype.WoltLabClean = function() {
                                html = html.replace(/<p>\u200B<\/p>/g, '<p><br></p>');
                                
                                // fix ampersands being replaced
-                               html = html.replace(/&amp;/g, '@@@WCF_AMPERSAND@@@');
+                               //html = html.replace(/&amp;/g, '@@@WCF_AMPERSAND@@@');
+                               html = html.replace(/&amp;/g, '&amp;WCF_AMPERSAND&amp;');
                                
                                html = mpOnSync.call(this, html);
                                
                                // restore ampersands
-                               html = html.replace(/@@@WCF_AMPERSAND@@@/g, '&amp;');
+                               //html = html.replace(/@@@WCF_AMPERSAND@@@/g, '&amp;');
+                               html = html.replace(/&WCF_AMPERSAND&/g, '&amp;');
                                
                                div.innerHTML = html;