Add \b to regexes in BlockLevelPass to avoid confusing tr & track
[lhc/web/wiklou.git] / includes / parser / BlockLevelPass.php
index e16cfd4..599fbf6 100644 (file)
@@ -286,20 +286,20 @@ class BlockLevelPass {
                                # @todo consider using a stack for nestable elements like span, table and div
                                $openMatch = preg_match(
                                        '/(?:<table|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|'
-                                               . '<p|<ul|<ol|<dl|<li|<\\/tr|<\\/td|<\\/th)/iS',
+                                               . '<p|<ul|<ol|<dl|<li|<\\/tr|<\\/td|<\\/th)\\b/iS',
                                        $t
                                );
                                $closeMatch = preg_match(
                                        '/(?:<\\/table|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|'
                                                . '<td|<th|<\\/?blockquote|<\\/?div|<hr|<\\/pre|<\\/p|<\\/mw:|'
                                                . Parser::MARKER_PREFIX
-                                               . '-pre|<\\/li|<\\/ul|<\\/ol|<\\/dl|<\\/?center)/iS',
+                                               . '-pre|<\\/li|<\\/ul|<\\/ol|<\\/dl|<\\/?center)\\b/iS',
                                        $t
                                );
 
                                if ( $openMatch || $closeMatch ) {
                                        $pendingPTag = false;
-                                       # @todo bug 5718: paragraph closed
+                                       # @todo T7718: paragraph closed
                                        $output .= $this->closeParagraph();
                                        if ( $preOpenMatch && !$preCloseMatch ) {
                                                $this->inPre = true;
@@ -353,7 +353,7 @@ class BlockLevelPass {
                                        }
                                }
                        }
-                       # somewhere above we forget to get out of pre block (bug 785)
+                       # somewhere above we forget to get out of pre block (T2785)
                        if ( $preCloseMatch && $this->inPre ) {
                                $this->inPre = false;
                        }
@@ -496,10 +496,12 @@ class BlockLevelPass {
                        case self::COLON_STATE_CLOSETAG:
                                # In a </tag>
                                if ( $c === ">" ) {
-                                       $ltLevel--;
-                                       if ( $ltLevel < 0 ) {
+                                       if ( $ltLevel > 0 ) {
+                                               $ltLevel--;
+                                       } else {
+                                               # ignore the excess close tag, but keep looking for
+                                               # colons. (This matches Parsoid behavior.)
                                                wfDebug( __METHOD__ . ": Invalid input; too many close tags\n" );
-                                               return false;
                                        }
                                        $state = self::COLON_STATE_TEXT;
                                }