C. Scott Ananian has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/328697 )
Change subject: Don't bail on single-line definition list due to excess close tags. ...................................................................... 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: ; <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 --- M includes/parser/BlockLevelPass.php M tests/parser/parserTests.txt 2 files changed, 30 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/97/328697/1 diff --git a/includes/parser/BlockLevelPass.php b/includes/parser/BlockLevelPass.php index e16cfd4..2ef599a 100644 --- a/includes/parser/BlockLevelPass.php +++ b/includes/parser/BlockLevelPass.php @@ -496,10 +496,12 @@ 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; } diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index b0e3d81..f38643c 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -3686,6 +3686,31 @@ !! end !! test +Definition lists: ignore colons inside tags +!! wikitext +;one <b>two : tag <i>fun:</i>:</b>: def +!! html +<dl><dt>one <b>two : 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 +<dl><dt>one</b>two </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 <dl> -- To view, visit https://gerrit.wikimedia.org/r/328697 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6306dcad6347abeb6ab001d35562f1ab9f374bd1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: C. Scott Ananian <canan...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits