From 92bbd5514cb0db9522252eb523fd66cc8348e2e1 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 10 Oct 2017 19:02:46 +0200 Subject: [PATCH] Fixed pasting of single-line content in Firefox --- .../redactor2/plugins/WoltLabPaste.js | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js index 55f876316f..a92236276e 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js @@ -36,15 +36,23 @@ $.Redactor.prototype.WoltLabPaste = function() { else if (this.detect.isFirefox()) { var types = e.originalEvent.clipboardData.types; if (types.length === 1 && types[0] === 'text/plain') { - var tmp = e.originalEvent.clipboardData.getData('text/plain'); + var tmp = WCF.String.escapeHTML(e.originalEvent.clipboardData.getData('text/plain')); firefoxPlainText = ''; - tmp.split("\n").forEach(function(line) { - line = line.trim(); - if (line === '') line = '
'; - - firefoxPlainText += '

' + line + '

'; - }); + var lines = tmp.split("\n"); + if (lines.length === 1) { + // paste single-line content as real plain text + firefoxPlainText = tmp; + } + else { + // plain newline characters do not work out well, mimic HTML instead + lines.forEach(function (line) { + line = line.trim(); + if (line === '') line = '
'; + + firefoxPlainText += '

' + line + '

'; + }); + } } } -- 2.20.1