X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fparser%2FParserOutput.php;h=346a151bee59a2616f5ea8015602be6c94d38f72;hp=e2efaff40f706a2b5d92f3f746d1a4368af75a69;hb=5859eff1b0c6e2438f4e21a4532e7f547d7cf2c2;hpb=74426f3cf796b149f1ae445e41815bbe148640b2 diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index e2efaff40f..346a151bee 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -301,10 +301,16 @@ class ParserOutput extends CacheTime { ] ); $startLen = strlen( $start ); $end = Html::closeElement( 'div' ); + $endPos = strrpos( $text, $end ); $endLen = strlen( $end ); - if ( substr( $text, 0, $startLen ) === $start && substr( $text, -$endLen ) === $end ) { - $text = substr( $text, $startLen, -$endLen ); + if ( substr( $text, 0, $startLen ) === $start && $endPos !== false + // if the closing div is followed by real content, bail out of unwrapping + && preg_match( '/^(?>\s*)*\s*$/s', substr( $text, $endPos + $endLen ) ) + ) { + $text = substr( $text, $startLen ); + $text = substr( $text, 0, $endPos - $startLen ) + . substr( $text, $endPos - $startLen + $endLen ); } }