From b479c0c9a4eec448ec4ad17ea225c85ebbd5a9d9 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 10 Feb 2015 13:51:57 +0100 Subject: [PATCH] Improved detection of embedded attachments --- .../js/3rdParty/redactor/plugins/wbbcode.js | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 81eb1f6eb6..15dd5ae06c 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -515,15 +515,24 @@ RedactorPlugins.wbbcode = function() { html = html.replace(/ ?]*?class="smiley" alt="([^"]+?)".*?> ?/gi, ' $1 '); // chrome, ie // attachments - html = html.replace(/]*?class="redactorEmbeddedAttachment[^"]*" data-attachment-id="(\d+)".*?( style="([^"]+)")?.*?>/gi, function(match, attachmentID, styleTag, style) { + html = html.replace(//gi, function(match, attributesBefore, attributesAfter) { + var $attributes = attributesBefore + ' ' + attributesAfter; + var $attachmentID; + if ($attributes.match(/data-attachment-id="(\d+)"/)) { + $attachmentID = RegExp.$1; + } + else { + return match; + } + var $float = 'none'; var $width = null; - if (style) { - style = style.split(';'); + if ($attributes.match(/style="([^"]+)"/)) { + var $styles = RegExp.$1.split(';'); - for (var $i = 0; $i < style.length; $i++) { - var $style = $.trim(style[$i]); + for (var $i = 0; $i < $styles.length; $i++) { + var $style = $.trim($styles[$i]); if ($style.match(/^float: (left|right)$/)) { $float = RegExp.$1; } @@ -533,14 +542,14 @@ RedactorPlugins.wbbcode = function() { } if ($width !== null) { - return '[attach=' + attachmentID + ',' + $float + ',' + $width + '][/attach]'; + return '[attach=' + $attachmentID + ',' + $float + ',' + $width + '][/attach]'; } else if ($float !== 'none') { - return '[attach=' + attachmentID + ',' + $float + '][/attach]'; + return '[attach=' + $attachmentID + ',' + $float + '][/attach]'; } } - return '[attach=' + attachmentID + '][/attach]'; + return '[attach=' + $attachmentID + '][/attach]'; }); // [img] -- 2.20.1