Don't bail on single-line definition list due to excess close tags.
authorC. Scott Ananian <cscott@cscott.net>
Thu, 22 Dec 2016 17:30:36 +0000 (12:30 -0500)
committerC. Scott Ananian <cscott@cscott.net>
Fri, 17 Feb 2017 21:34:55 +0000 (16:34 -0500)
When parsing a single line definition list, we track nested tags so that:

; <b>foo:bar</b>: baz

breaks before `baz`, not between `foo` and `bar`.  But we currently bail
out of this algorithm entirely if we see a mismatched close tag.  We should
just ignore the unmatched tag, like Parsoid does.

Change-Id: I6306dcad6347abeb6ab001d35562f1ab9f374bd1

includes/parser/BlockLevelPass.php
tests/parser/parserTests.txt

index e16cfd4..2ef599a 100644 (file)
@@ -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;
                                }
index a94b276..0ba60aa 100644 (file)
@@ -3682,6 +3682,32 @@ Definition lists: self-closed tag
 
 !! end
 
+!! test
+Definition lists: ignore colons inside tags
+!! wikitext
+;one <b>two : tag <i>fun:</i>:</b>: def
+!! html
+<dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
+<dd> def</dd></dl>
+
+!! end
+
+!! test
+Definition lists: excess closed tags
+!! wikitext
+;one</b>two : bad tag fun
+!! html/php+tidy
+<dl>
+<dt>onetwo&#160;</dt>
+<dd>bad tag fun</dd>
+</dl>
+!! html/parsoid
+<dl>
+<dt>onetwo</dt>
+<dd>bad tag fun</dd>
+</dl>
+!! end
+
 !! test
 Bug 11748: Literal closing tags
 !! wikitext