From 3a8a986e35ab5ae1328b2147ec31fc2d27caf9b8 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Thu, 22 Dec 2016 12:30:36 -0500 Subject: [PATCH] Don't bail on single-line definition list due to excess close tags. When parsing a single line definition list, we track nested tags so that: ; foo:bar: 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 | 8 +++++--- tests/parser/parserTests.txt | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/includes/parser/BlockLevelPass.php b/includes/parser/BlockLevelPass.php index e16cfd4688..2ef599a398 100644 --- a/includes/parser/BlockLevelPass.php +++ b/includes/parser/BlockLevelPass.php @@ -496,10 +496,12 @@ class BlockLevelPass { case self::COLON_STATE_CLOSETAG: # In a 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; } diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index a94b27633b..0ba60aaa7e 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -3682,6 +3682,32 @@ Definition lists: self-closed tag !! end +!! test +Definition lists: ignore colons inside tags +!! wikitext +;one two : tag fun::: def +!! html +
one two : tag fun::
+
def
+ +!! end + +!! test +Definition lists: excess closed tags +!! wikitext +;onetwo : bad tag fun +!! html/php+tidy +
+
onetwo 
+
bad tag fun
+
+!! html/parsoid +
+
onetwo
+
bad tag fun
+
+!! end + !! test Bug 11748: Literal closing tags !! wikitext -- 2.20.1