From: Alexander Ebert Date: Tue, 10 Feb 2015 12:51:57 +0000 (+0100) Subject: Improved detection of embedded attachments X-Git-Tag: 2.1.0_RC_1~44 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b479c0c9a4eec448ec4ad17ea225c85ebbd5a9d9;p=GitHub%2FWoltLab%2FWCF.git Improved detection of embedded attachments --- 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]