From: Arlo Breault Date: Wed, 20 Mar 2019 20:32:10 +0000 (-0400) Subject: parser: Count occurrences of newlines X-Git-Tag: 1.34.0-rc.0~2455 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=4d7dcf5c963ee39a197b9e02a7aeb09c1f3ac8aa;p=lhc%2Fweb%2Fwiklou.git parser: Count occurrences of newlines StringUtils::explode() returns an ExplodeIterator if the number of separators is too high, which doesn't implement count. So count the way that explode does. Bug: T218817 Change-Id: I22eebb70af1b19d7c25241fc78bfcced4470e78a --- diff --git a/includes/parser/BlockLevelPass.php b/includes/parser/BlockLevelPass.php index b2bcc8c0a3..6611e20c0a 100644 --- a/includes/parser/BlockLevelPass.php +++ b/includes/parser/BlockLevelPass.php @@ -192,6 +192,7 @@ class BlockLevelPass { # happening here is handling of block-level elements p, pre, # and making lists from lines starting with * # : etc. $textLines = StringUtils::explode( "\n", $text ); + $lineCount = substr_count( $text, "\n" ) + 1; $lastPrefix = $output = ''; $this->DTopen = $inBlockElem = false; @@ -199,7 +200,6 @@ class BlockLevelPass { $pendingPTag = false; $inBlockquote = false; - $lineCount = count( $textLines ); foreach ( $textLines as $i => $inputLine ) { # Fix up $lineStart if ( !$this->lineStart ) {