Proper cleanup of incorrectly used lists
authorAlexander Ebert <ebert@woltlab.com>
Tue, 10 Feb 2015 13:09:15 +0000 (14:09 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 10 Feb 2015 13:09:15 +0000 (14:09 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js

index 15dd5ae06c6e65d3e6faf3b4b4a57cb3a996f71e..2ec6061dc432822a2119e99cdef409d9d39d5513 100644 (file)
@@ -826,6 +826,27 @@ RedactorPlugins.wbbcode = function() {
                        // [align]
                        data = data.replace(/\[align=(left|right|center|justify)\]([\s\S]*?)\[\/align\]/gi,'<div style="text-align: $1">$2</div>');
                        
+                       // search for [*] not preceeded by [list by searching for the first occurence of [list and then check the left
+                       var $firstList = data.indexOf('[list');
+                       if ($firstList > 0) {
+                               var $tmp = data.substr(0, $firstList);
+                               $tmp = $tmp.replace(/\[\*\]/g, '');
+                               data = $tmp  + data.substr($firstList);
+                       }
+                       
+                       // search for [*] not followed by [/list]
+                       var $lastList = data.indexOf('[/list]');
+                       if ($lastList === -1) {
+                               // drop all [list*] and [*]
+                               data = data.replace(/\[\*\]/g, '');
+                               data = data.replace(/\[list[^\]]*\]/g, '');
+                       }
+                       else {
+                               var $tmp = data.substr($lastList + 7);
+                               $tmp = $tmp.replace(/\[\*\]/g, '');
+                               data = data.substr(0, $lastList + 7) + $tmp;
+                       }
+                       
                        // [*]
                        data = data.replace(/\[\*\]([\s\S]*?)(?=\[\*\]|\[\/list\])/gi, function(match, content) {
                                return '<li>' + $.trim(content) + '</li>';