From: Alexander Ebert Date: Mon, 24 Jun 2019 13:52:42 +0000 (+0200) Subject: Workaround for the faulty link tokenizer in Redactor X-Git-Tag: 5.2.0_Alpha_1~17^2~4^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ad123a040988b18a83cfb0957d5abedcf8ebb15a;p=GitHub%2FWoltLab%2FWCF.git Workaround for the faulty link tokenizer in Redactor --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js index 9e48cf5af5..97bb448639 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js @@ -421,7 +421,7 @@ $.Redactor.prototype.WoltLabClean = function() { if (data.links && this.opts.pasteLinks) { elBySelAll('a', div, function(link) { if (link.href) { - link.outerHTML = '#####[a href="' + link.href + '"]#####' + link.innerHTML + '#####[/a]#####'; + link.outerHTML = '#@###[a href="' + link.href + '"]###@#' + link.innerHTML + '#@###[/a]###@#'; } }); @@ -489,6 +489,15 @@ $.Redactor.prototype.WoltLabClean = function() { html = div.innerHTML; } + + // The original code uses a slightly different pattern that did not distinguish between the + // opening and closing "#####" pattern, causing some degree of ambiguity and false-positives. + // links & images + if ((data.links && this.opts.pasteLinks) || (data.images && this.opts.pasteImages)) + { + html = html.replace(new RegExp('#@###\\[', 'gi'), '<'); + html = html.replace(new RegExp('\\]###@#', 'gi'), '>'); + } return mpReconvertTags.call(this, html, data); }).bind(this);