Properly handle reverted bbcodes
authorAlexander Ebert <ebert@woltlab.com>
Mon, 18 Jul 2016 13:25:15 +0000 (15:25 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 18 Jul 2016 13:25:37 +0000 (15:25 +0200)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php

index 9e4d154abdcaaf6086fd1a98787efaf50c330a48..fd01b195308385edb52d316c701a9095e53acc32 100644 (file)
@@ -91,19 +91,26 @@ class HtmlInputNodeWoltlabMetacodeMarker extends AbstractHtmlInputNode {
                };
                
                foreach ($groups as $name => $pairs) {
+                       $needsReindex = false;
                        for ($i = 0, $length = count($pairs); $i < $length; $i++) {
                                $pair = $pairs[$i];
                                if ($isInsideCode($pair['open']) || $isInsideCode($pair['close'])) {
                                        $pair['attributes'] = $htmlNodeProcessor->parseAttributes($pair['attributes']);
                                        $this->convertToBBCode($name, $pair);
                                        
+                                       $needsReindex = true;
                                        unset($groups[$name][$i]);
                                        
                                        if (empty($groups[$name])) {
+                                               $needsReindex = false;
                                                unset($groups[$name]);
                                        }
                                }
                        }
+                       
+                       if ($needsReindex) {
+                               $groups[$name] = array_values($groups[$name]);
+                       }
                }
                
                return $groups;