From 889a55ffc86c0dfd005bd054f41b59adc1365dbc Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 4 Dec 2017 14:00:51 +0100 Subject: [PATCH] Prevent Redactor from interefering with text pasted into plaintext blocks --- .../js/3rdParty/redactor2/plugins/WoltLabClean.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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'); -- 2.20.1