From: Alexander Ebert Date: Mon, 4 Dec 2017 13:00:51 +0000 (+0100) Subject: Prevent Redactor from interefering with text pasted into plaintext blocks X-Git-Tag: 3.1.0_Beta_4~23 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=889a55ffc86c0dfd005bd054f41b59adc1365dbc;p=GitHub%2FWoltLab%2FWCF.git Prevent Redactor from interefering with text pasted into plaintext blocks --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js index 33cf7f26cc..044a18d734 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js @@ -121,15 +121,13 @@ $.Redactor.prototype.WoltLabClean = function() { var mpOnPaste = this.clean.onPaste; this.clean.onPaste = (function (html, data, insert) { if (data.pre || this.utils.isCurrentOrParent('kbd')) { - // prevent method call when data.pre is true - var mpRemoveEmptyInlineTags = this.clean.removeEmptyInlineTags; - this.clean.removeEmptyInlineTags = function(html) { return html; }; - - html = mpOnPaste.call(this, html, data, insert); - - this.clean.removeEmptyInlineTags = mpRemoveEmptyInlineTags; + // instead of calling the original method, we'll use a subset of the cleaning + // tasks in order to avoid malformed HTML being sanitized by Redactor + if (data.pre && this.opts.preSpaces) { + html = html.replace(/\t/g, new Array(this.opts.preSpaces + 1).join(' ')); + } - return html; + return WCF.String.escapeHTML(html); } var div = elCreate('div');