Fixed some regex being too greedy
authorAlexander Ebert <ebert@woltlab.com>
Tue, 31 Mar 2015 11:36:57 +0000 (13:36 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 31 Mar 2015 11:36:57 +0000 (13:36 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js

index 039e3f95145fe4ee5a057cebc8bef51167cfaabc..46204aea268b6b320b86ca596af9aa333f30ae90 100644 (file)
@@ -290,7 +290,7 @@ RedactorPlugins.wbbcode = function() {
                        
                        // preserve code listings
                        var $cachedCodeListings = { };
-                       html = html.replace(/<div(.*?)class="codeBox[^"]+"(.*?)>\n*<div>[\s\S]+?<ol start="(\d+)">([\s\S]+?)<\/ol>\n*<\/div>\n*<\/div>/g, function(match, codeBoxAttributes1, codeBoxAttributes2, lineNumber, codeContent) {
+                       html = html.replace(/<div([^>]+?)class="codeBox[^"]+"([^>]*?)>\n*<div>[\s\S]+?<ol start="(\d+)">([\s\S]+?)<\/ol>\n*<\/div>\n*<\/div>/g, function(match, codeBoxAttributes1, codeBoxAttributes2, lineNumber, codeContent) {
                                var $attributes = codeBoxAttributes1 + ' ' + codeBoxAttributes2;
                                var $highlighter = '';
                                var $filename = '';
@@ -616,7 +616,7 @@ RedactorPlugins.wbbcode = function() {
                        html = html.replace(/ ?<img [^>]*?class="smiley"[^>]*?alt="([^"]+?)"[^>]*?> ?/gi, ' $1 '); // chrome, ie
                        
                        // attachments
-                       html = html.replace(/<img(.*?)class="[^"]*redactorEmbeddedAttachment[^"]*"(.*?)>/gi, function(match, attributesBefore, attributesAfter) {
+                       html = html.replace(/<img([^>]*?)class="[^"]*redactorEmbeddedAttachment[^"]*"([^>]*?)>/gi, function(match, attributesBefore, attributesAfter) {
                                var $attributes = attributesBefore + ' ' + attributesAfter;
                                var $attachmentID;
                                if ($attributes.match(/data-attachment-id="(\d+)"/)) {
@@ -654,7 +654,7 @@ RedactorPlugins.wbbcode = function() {
                        });
                        
                        // [img]
-                       html = html.replace(/<img [^>]*?src=(["'])([^"']+?)\1.*?style="([^"]+)".*?>/gi, function(match, quotationMarks, source, style) {
+                       html = html.replace(/<img [^>]*?src=(["'])([^"']+?)\1[^>]*?style="([^"]+)"[^>]*?>/gi, function(match, quotationMarks, source, style) {
                                var $float = 'none';
                                var $width = 0;
                                
@@ -679,7 +679,7 @@ RedactorPlugins.wbbcode = function() {
                                return "[img]" + source + "[/img]";
                        });
                        
-                       html = html.replace(/<img [^>]*?src=(["'])([^"']+?)\1.*?>/gi, '[img]$2[/img]');
+                       html = html.replace(/<img [^>]*?src=(["'])([^"']+?)\1[^>]*?>/gi, '[img]$2[/img]');
                        
                        // [*]
                        html = html.replace(/<li>/gi, '[*]');