TTO has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/330896 )

Change subject: Fix parsing of <pre> tags generated by extension tag hooks
......................................................................

Fix parsing of <pre> tags generated by extension tag hooks

When this part of BlockLevelPass::execute() encounters a block-level tag,
such as <hr>, one of $openMatch or $closeMatch will be truthy.

Without this patch, $this->closeParagraph() is unconditionally called in
this situation, which sets $this->inPre = false. If we're already inside a
<pre> tag, this makes the parser think we're no longer in a <pre>
environment, so it starts wrapping the <pre> tag's content in <p> tags as
if it was processing regular content.

We should only call $this->closeParagraph() in the case that (a) we are not
inside a <pre> tag, or (b) the block-level tag that is being opened is
itself a <pre> tag (in which case $preOpenMatch will be truthy, and
$this->inPre will have already been set to true).

This doesn't affect the parsing of <pre> tags that are written in wikitext,
since their content isn't parsed. It only affects hooks and the like that
return <pre> tags.

This doesn't solve the task T7718 that is mentioned in the code comment,
but if the testwiki test cases linked there are anything to go by, it
doesn't make the problem worse in any way.

This is required for Poem change I754f2e84f7d6efc0829765c82297f2de5f9ca149.

Change-Id: I469e633fc41d8ca73653c7e982c591092dcb1708
---
M includes/parser/BlockLevelPass.php
1 file changed, 6 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/96/330896/1

diff --git a/includes/parser/BlockLevelPass.php 
b/includes/parser/BlockLevelPass.php
index cbacd34..cc95f3b 100644
--- a/includes/parser/BlockLevelPass.php
+++ b/includes/parser/BlockLevelPass.php
@@ -298,8 +298,12 @@
 
                                if ( $openMatch || $closeMatch ) {
                                        $pendingPTag = false;
-                                       # @todo bug 5718: paragraph closed
-                                       $output .= $this->closeParagraph();
+                                       // Only close the paragraph if we're 
not inside a <pre> tag, or if
+                                       // that <pre> tag has just been opened
+                                       if ( !$this->inPre || $preOpenMatch ) {
+                                               // @todo T7718: paragraph closed
+                                               $output .= 
$this->closeParagraph();
+                                       }
                                        if ( $preOpenMatch && !$preCloseMatch ) 
{
                                                $this->inPre = true;
                                        }

-- 
To view, visit https://gerrit.wikimedia.org/r/330896
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I469e633fc41d8ca73653c7e982c591092dcb1708
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: TTO <at.li...@live.com.au>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to