diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index e803f2db1de..f3df5a90554 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -6483,12 +6483,12 @@ class Parser { * @unstable */ public static function extractBody( string $text ): string { - $text = preg_replace( '!^.*?]*>!s', '', $text, 1 ); + $text = preg_replace( '!^(?>.*?]*+>!s', '', $text, 1 ); if ( $text === null ) { - // T388729: this should never happen + // T399064: this should never happen throw new RuntimeException( 'Regex failed: ' . preg_last_error() ); } - $text = preg_replace( '!\s*\s*$!', '', $text, 1 ); + $text = preg_replace( '!\s*+\s*+$!', '', $text, 1 ); return $text; }